mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
remove default expiry in jwt token
This commit is contained in:
parent
9cb231391a
commit
8a342daef9
5 changed files with 25 additions and 14 deletions
|
@ -82,6 +82,9 @@ module.exports = function(options) {
|
|||
, name: user.cn
|
||||
}
|
||||
, secret: options.secret
|
||||
, header: {
|
||||
exp: Date.now() + 24 * 3600
|
||||
}
|
||||
})
|
||||
res.status(200)
|
||||
.json({
|
||||
|
|
|
@ -74,6 +74,9 @@ module.exports = function(options) {
|
|||
, name: req.body.name
|
||||
}
|
||||
, secret: options.secret
|
||||
, header: {
|
||||
exp: Date.now() + 24 * 3600
|
||||
}
|
||||
})
|
||||
res.status(200)
|
||||
.json({
|
||||
|
|
|
@ -39,6 +39,9 @@ module.exports = function(options) {
|
|||
, name: req.user.email.split('@', 1).join('')
|
||||
}
|
||||
, secret: options.secret
|
||||
, header: {
|
||||
exp: Date.now() + 24 * 3600
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -337,14 +337,12 @@ module.exports = function(options) {
|
|||
dbapi.resetUserSettings(user.email)
|
||||
})
|
||||
.on('user.keys.accessToken.generate', function(data) {
|
||||
var expiry = Date.now() + 100 * 365 * 24 * 3600
|
||||
, jwt = jwtutil.encode({
|
||||
var jwt = jwtutil.encode({
|
||||
payload: {
|
||||
email: user.email
|
||||
, name: user.name
|
||||
}
|
||||
, secret: options.secret
|
||||
, expiry: expiry
|
||||
})
|
||||
|
||||
var tokenId = uuid.v4()
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
var assert = require('assert')
|
||||
var jws = require('jws')
|
||||
var _ = require('lodash')
|
||||
|
||||
module.exports.encode = function(options) {
|
||||
assert.ok(options.payload, 'payload required')
|
||||
assert.ok(options.secret, 'secret required')
|
||||
|
||||
var expiry = options.expiry || Date.now() + 24 * 3600
|
||||
var header = {
|
||||
alg: 'HS256'
|
||||
}
|
||||
|
||||
if (options.header) {
|
||||
header = _.merge(header, options.header)
|
||||
}
|
||||
|
||||
return jws.sign({
|
||||
header: {
|
||||
alg: 'HS256'
|
||||
, exp: expiry
|
||||
}
|
||||
header: header
|
||||
, payload: options.payload
|
||||
, secret: options.secret
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue