1
This commit is contained in:
parent
3b2e5fd410
commit
ccaa2e8bee
@ -5,8 +5,14 @@ const jwksClient = require('jwks-rsa');
|
|||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
|
|
||||||
const jwksKeyHash = {};
|
const jwksKeyHash = {};
|
||||||
|
const jwksKeyLockHash = {};
|
||||||
|
|
||||||
async function asyncGetKey(jkwsUri, header, cb) {
|
async function asyncGetKey(jkwsUri, 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
|
||||||
});
|
});
|
||||||
@ -28,21 +34,18 @@ function asyncVerify(jwksUri, data) {
|
|||||||
err: null,
|
err: null,
|
||||||
decoded: null
|
decoded: null
|
||||||
};
|
};
|
||||||
function getKey(header, cb) {
|
jwt.verify
|
||||||
if (jwksUri in jwksKeyHash) {
|
(data,
|
||||||
const c = jwksKeyHash[jwksUri];
|
(header, cb) => {
|
||||||
cb(null, c['key']);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
asyncGetKey(jwksUri, header, cb);
|
asyncGetKey(jwksUri, header, cb);
|
||||||
}
|
},
|
||||||
jwt.verify(data, getKey, function(err, decoded) {
|
(err, decoded) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
console.log(decoded);
|
console.log(decoded);
|
||||||
ret.err = err;
|
ret.err = err;
|
||||||
ret.decoded = decoded;
|
ret.decoded = decoded;
|
||||||
resolve(ret);
|
resolve(ret);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user