From 1b632d067ef7e69f8fc5e78f2b5b095da2b802f3 Mon Sep 17 00:00:00 2001 From: Jitendra Adhikari Date: Sun, 25 Aug 2019 08:07:22 +0700 Subject: [PATCH] docs: add examples with 'kid' --- README.md | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 514e183..5df34d3 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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