Merge pull request #167 from prmtl/feature/pass-token-header
Pass token header to secret fetching function
This commit is contained in:
commit
16fefb61bc
@ -243,13 +243,18 @@ function getSecret (request, secret, token, callback) {
|
||||
return callback({ code: 'invalid_token', message: 'jwt signature is required' });
|
||||
}
|
||||
|
||||
let decodedToken = jwt.decode(token);
|
||||
let decodedToken = jwt.decode(token, { complete: true });
|
||||
|
||||
if (!decodedToken) {
|
||||
return callback({ code: 'invalid_token', message: 'jwt malformed' });
|
||||
}
|
||||
|
||||
secret(request, decodedToken, callback);
|
||||
const arity = secret.length;
|
||||
if (arity == 4) {
|
||||
secret(request, decodedToken.header, decodedToken.payload, callback);
|
||||
} else { // arity == 3
|
||||
secret(request, decodedToken.payload, callback);
|
||||
}
|
||||
} else {
|
||||
callback(null, secret);
|
||||
}
|
||||
|
Reference in New Issue
Block a user