Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/4rthem/jwt-request-signer

Protect access to your resources with JWT
https://github.com/4rthem/jwt-request-signer

Last synced: 13 days ago
JSON representation

Protect access to your resources with JWT

Awesome Lists containing this project

README

        

# JWT Request Signer

Sign your URLs with a JWT token to protect access to your resources.

[![Build Status](https://travis-ci.com/4rthem/jwt-request-signer.svg?branch=master)](https://travis-ci.com/4rthem/jwt-request-signer)

## Installation

```bash
composer require arthem/jwt-request-signer
# add a library that implements psr/http-factory-implementation
composer require nyholm/psr7
```

## Usage

Generate signed URL for your resources (an image for instance):
```php
signRequest($requestToSign);

$signedUri = (string) $signedRequest->getUri();
```

Now add authorization to your resource:
```php
validateSignedRequest($currentRequest);
} catch (InvalidTokenException $e) {
echo "Access denied";
exit;
}

// Stream your image here...
```

### Frameworks

Symfony [request-signer-bundle](https://github.com/4rthem/request-signer-bundle)

## Configuration

### Determinant headers

In order to offer a strict protection, most headers are signed.
You can exclude some headers that are not determinant:

```php
addUnsignedHeader('X-Time');
```