Skip to content

Commit

Permalink
Merge pull request #71 from avoidwork/jwt
Browse files Browse the repository at this point in the history
Adding JWT strategy
  • Loading branch information
avoidwork authored Dec 21, 2016
2 parents a70b1f4 + 5eda63e commit 1304ebd
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 84 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ Google authentication (OpenID) will create `/auth`, `/auth/google`, & `/auth/goo
}
```

### JWT
JWT (JSON Web Token) authentication is stateless and does not have an entry point. The `auth(token, callback)` function must verify `token.sub`, and must execute `callback(err, user)`.

This authentication strategy relies on out-of-band information for the `secret`, and other optional token attributes.

```
{
"auth": {
"jwt": {
"enabled": true,
"auth": function (token, cb) { ... }, /* Authentication handler, to 'find' or 'create' a User */
"algorithms": [], /* Optional signing algorithms, defaults to ["HS256", "HS384", "HS512"] */
"audience": "", /* Optional, used to verify `aud` */
"issuer: "", /* Optional, used to verify `iss` */
"ignoreExpiration": false, /* Optional, set to `true` to ignore expired tokens */
"scheme": "Bearer", /* Optional, set to specify the `Authorization` scheme */
"secretOrKey": ""
}
"protect": ["/private"]
}
}
```

### LinkedIn
LinkedIn authentication will create `/auth`, `/auth/linkedin`, & `/auth/linkedin/callback` routes. `auth(token, tokenSecret, profile, callback)` must execute `callback(err, user)`.

Expand Down
9 changes: 9 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
"enabled": false,
"auth": null
},
"jwt": {
"enabled": false,
"audience": "",
"algorithms": ["HS256", "HS384", "HS512"],
"ignoreExpiration": false,
"issuer": "",
"scheme": "Bearer",
"secretOrKey": ""
},
"linkedin": {
"enabled": false,
"auth": null,
Expand Down
2 changes: 1 addition & 1 deletion lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Tenso {
});
this.server.tenso = this;
this.websocket = null;
this.version = "4.0.0";
this.version = "";
}

error (req, res, err) {
Expand Down
Loading

0 comments on commit 1304ebd

Please sign in to comment.