Skip to content

Commit

Permalink
Make clearer sections in the Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongodin authored and jfromaniello committed Apr 7, 2020
1 parent d3e86bf commit 8662579
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ app.get('/protected',
});
```

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)).

> 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/).
### Additional Options

You can specify audience and/or issuer as well:

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

### Retrieving the Decoded Payload

By default, the decoded token is attached to `req.user` but can be configured with the `requestProperty` option.


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

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

### Customizing Token Location

A custom function for extracting the token from a request can be specified with
the `getToken` option. This is useful if you need to pass the token through a
query parameter or a cookie. You can throw an error in this function and it will
Expand Down

0 comments on commit 8662579

Please sign in to comment.