-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change: DEVX-8554 Switch to JWT for client tokens
- Loading branch information
1 parent
d18c642
commit fc5abe3
Showing
6 changed files
with
33 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
var jwt = require('jsonwebtoken'); | ||
|
||
module.exports = function (config) { | ||
module.exports = function (config, additionalClaims) { | ||
var currentTime = Math.floor(new Date() / 1000); | ||
var token = jwt.sign({ | ||
const initialClaims = { | ||
iss: config.apiKey, | ||
ist: 'project', | ||
iat: currentTime, | ||
exp: currentTime + config.auth.expire | ||
}, config.apiSecret); | ||
exp: additionalClaims?.expire_time || currentTime + config.auth.expire | ||
}; | ||
|
||
const claims = {...initialClaims, ...additionalClaims}; | ||
|
||
var token = jwt.sign(claims, config.apiSecret); | ||
|
||
return token; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict'; | ||
|
||
// Test Helpers | ||
var qs = require('querystring'); | ||
var crypto = require('crypto'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters