Skip to content

Commit 8662579

Browse files
aarongodinjfromaniello
authored andcommittedApr 7, 2020
Make clearer sections in the Readme
1 parent d3e86bf commit 8662579

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎README.md

+8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ app.get('/protected',
2525
});
2626
```
2727

28+
The decoded JWT payload is available on the request via the `user` property. This can be configured using the `requestProperty` option ([see below](#retrieving-the-decoded-payload)).
29+
2830
> The default behavior of the module is to extract the JWT from the `Authorization` header as an [OAuth2 Bearer token](https://oauth.net/2/bearer-tokens/).
2931
32+
### Additional Options
33+
3034
You can specify audience and/or issuer as well:
3135

3236
```javascript
@@ -62,6 +66,8 @@ var publicKey = fs.readFileSync('/path/to/public.pub');
6266
jwt({ secret: publicKey });
6367
```
6468

69+
### Retrieving the Decoded Payload
70+
6571
By default, the decoded token is attached to `req.user` but can be configured with the `requestProperty` option.
6672

6773

@@ -77,6 +83,8 @@ jwt({ secret: publicKey, resultProperty: 'locals.user' });
7783

7884
Both `resultProperty` and `requestProperty` utilize [lodash.set](https://lodash.com/docs/4.17.2#set) and will accept nested property paths.
7985

86+
### Customizing Token Location
87+
8088
A custom function for extracting the token from a request can be specified with
8189
the `getToken` option. This is useful if you need to pass the token through a
8290
query parameter or a cookie. You can throw an error in this function and it will

0 commit comments

Comments
 (0)
Please sign in to comment.