Skip to content

Commit

Permalink
Updated README documentation after testing custom handler implementat…
Browse files Browse the repository at this point in the history
…ion in the integration testing tool.
  • Loading branch information
RobDWaller committed Mar 3, 2020
1 parent f81b082 commit 273f232
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ For more information on creating, parsing and validating tokens please read the

If you would like to retrieve the JSON Web Token from the request outside of the normal middleware authorisation flow you can use the request helper class.

It allows you to retrive the token itself or just access the token's payload or header.
It allows you to retrieve the token itself or just access the token's payload or header.

```php
require 'vendor/autoload.php';
Expand Down Expand Up @@ -171,6 +171,7 @@ Next you will need to extend the `PsrJwt\Auth\Authorise` class as this will give
```php
// An example JWT Authorisation Handler.
use PsrJwt\Auth\Authorise;
use PsrJwt\JwtAuthMiddleware;
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -196,6 +197,15 @@ class MyHandler extends Authorise implements RequestHandlerInterface
);
}
}

// Add Handler to Middleware.
$middleware = new JwtAuthMiddleware(new MyHandler('secret', 'token-key'));

// Add Middleware to Slim PHP route.
$app->get('/my/route', function (ServerRequestInterface $request, ResponseInterface $response) {
$response->getBody()->write("OK!");
return $response;
})->add($middleware);
```

## License
Expand Down

0 comments on commit 273f232

Please sign in to comment.