updated README to include information about Auth Header Requirement - DK/MW
This commit is contained in:
parent
ef0983a702
commit
17da40f720
22
README.md
22
README.md
@ -108,17 +108,9 @@ For more validation options see [auth0/jsonwebtoken](https://github.com/auth0/no
|
|||||||
Append the jwt token using query string:
|
Append the jwt token using query string:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
//// token part of query string ////
|
|
||||||
var socket = io.connect('http://localhost:9000', {
|
var socket = io.connect('http://localhost:9000', {
|
||||||
'query': 'token=' + your_jwt
|
'query': 'token=' + your_jwt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//// token coming in as Authorization Header ////
|
|
||||||
var socket = io.connect('http://localhost:9000', {
|
|
||||||
'extraHeaders': { Authorization: `Bearer ${your_jwt}` }
|
|
||||||
});
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Append the jwt token using 'Authorization Header' (Bearer Token):
|
Append the jwt token using 'Authorization Header' (Bearer Token):
|
||||||
@ -131,6 +123,20 @@ var socket = io.connect('http://localhost:9000', {
|
|||||||
|
|
||||||
Both options can be combined or used optionally.
|
Both options can be combined or used optionally.
|
||||||
|
|
||||||
|
### Authorization Header Requirement
|
||||||
|
|
||||||
|
Require Bearer Tokens to be passed in as an Authorization Header
|
||||||
|
|
||||||
|
**Server side**:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
io.use(socketioJwt.authorize({
|
||||||
|
secret: 'your secret or public key',
|
||||||
|
handshake: true,
|
||||||
|
auth_header_required: true
|
||||||
|
}));
|
||||||
|
```
|
||||||
|
|
||||||
### Handling token expiration
|
### Handling token expiration
|
||||||
|
|
||||||
**Server side**
|
**Server side**
|
||||||
|
Reference in New Issue
Block a user