mirror of
https://github.com/plankanban/planka.git
synced 2025-07-21 22:29:42 +02:00
feat: Additional httpOnly token for enhanced security in browsers
This commit is contained in:
parent
d4043c9726
commit
50519f1bcd
18 changed files with 171 additions and 48 deletions
30
server/api/helpers/utils/verify-jwt-token.js
Normal file
30
server/api/helpers/utils/verify-jwt-token.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
const jwt = require('jsonwebtoken');
|
||||
|
||||
module.exports = {
|
||||
sync: true,
|
||||
|
||||
inputs: {
|
||||
token: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
invalidToken: {},
|
||||
},
|
||||
|
||||
fn(inputs) {
|
||||
let payload;
|
||||
try {
|
||||
payload = jwt.verify(inputs.token, sails.config.session.secret);
|
||||
} catch (error) {
|
||||
throw 'invalidToken';
|
||||
}
|
||||
|
||||
return {
|
||||
subject: payload.sub,
|
||||
issuedAt: new Date(payload.iat * 1000),
|
||||
};
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue