Skip to content

Commit

Permalink
step 5: Token Endpoint - generate ID Token as valid JWT
Browse files Browse the repository at this point in the history
  • Loading branch information
Ballinette committed Oct 12, 2019
1 parent a8e8bf1 commit 483a6a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ module.exports = {
redirect_logout_uri: 'http://localhost:3000/logout-callback',
},
],
jwt: {
algo: 'HS256',
key: 'changeme',
ttl: 3600000, // 1 hour
},
};
15 changes: 14 additions & 1 deletion helpers/jwt.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
const
njwt = require('njwt'),
config = require('../config');

const getIdToken = (sub, client_id, nonce) => {
return 'idToken' // @TODO: generate valid JWT
const payload = {
sub,
nonce,
iss: config.issuer,
aud: client_id,
};

const jwt = njwt.create(payload, config.jwt.key, config.jwt.algo);
jwt.setExpiration(Date.now() + config.jwt.ttl);

return jwt.compact();
};

module.exports = {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"ejs": "^2.6.1",
"express": "^4.16.3",
"express-session": "^1.15.6",
"njwt": "^1.0.0",
"node-csv-query": "^0.1.0",
"sessionstore": "^1.3.3"
},
Expand Down

0 comments on commit 483a6a7

Please sign in to comment.