1
This commit is contained in:
parent
91814441c9
commit
c0a1be42e7
@ -12,24 +12,26 @@ function asyncVerify(jwksUri, data) {
|
||||
err: null,
|
||||
decoded: null
|
||||
};
|
||||
function getKey(header, cb ) {
|
||||
function getKey(header, cb) {
|
||||
if (jwksUri in jwksKeyHash) {
|
||||
const c = jwksKeyHash[jwksUri];
|
||||
cb(null, c['key']);
|
||||
return;
|
||||
}
|
||||
const client = jwksClient({
|
||||
jwksUri: jwksUri
|
||||
});
|
||||
console.log(header);
|
||||
client.getSigningKey(header.kid, function(err, key) {
|
||||
console.log(err);
|
||||
console.log(key);
|
||||
const signingKey = key.publicKey || key.rsaPublicKey;
|
||||
if (!err) {
|
||||
jwksKeyHash[jwksUri] = {
|
||||
'key': key,
|
||||
'last_refresh_time': utils.getUtcTime()
|
||||
'lastRefreshTime': utils.getUtcTime()
|
||||
};
|
||||
}
|
||||
cb(null, signingKey);
|
||||
});
|
||||
};
|
||||
}
|
||||
jwt.verify(data, getKey, function(err, decoded) {
|
||||
console.log(err);
|
||||
console.log(decoded);
|
||||
|
Loading…
x
Reference in New Issue
Block a user