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