Skip to content

Commit

Permalink
docs: add examples with 'kid'
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Aug 25, 2019
1 parent 9be3ae9 commit 1b632d0
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ If you are new to JWT or want to refresh your familiarity with it, please check
composer require adhocore/jwt
```

## Features

- Six algorithms supported:
```
'HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512'
```
- `kid` support
- Leeway support 0-120 seconds.
- Timestamp spoofing for tests.
- Passphrase support for `RS*` algos.

## Usage

```php
Expand Down Expand Up @@ -93,15 +104,19 @@ $jwt->parse($token);
$jwt->setTestTimestamp();
```

## Features
> Examples with `kid`:
- Six algorithms supported:
```
'HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512'
```php
$jwt = new JWT(['key1' => 'secret1', 'key2' => 'secret2']);

// Use key2
$token = $jwt->encode(['a' => 1, 'exp' => time() + 1000], ['kid' => 'key2']);

$payload = $jwt->decode($token);

$token = $jwt->encode(['a' => 1, 'exp' => time() + 1000], ['kid' => 'key3']);
// -> Exception with message Unknown key ID key3
```
- Leeway support 0-120 seconds.
- Timestamp spoofing for tests.
- Passphrase support for `RS*` algos.

### Integration

Expand Down

0 comments on commit 1b632d0

Please sign in to comment.