Skip to content

Commit 443ad1b

Browse files
committed
finetune options handling
1 parent b2052b6 commit 443ad1b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ let options
2525
* @returns {Promise} The error-handled promise
2626
*/
2727
function validateOffline (token) {
28+
const { publicKey, verifyOpts = {} } = options
29+
2830
return new Promise((resolve, reject) => {
29-
jwt.verify(token, options.publicKey, options.verifyOpts, (err, decoded) => {
31+
jwt.verify(token, publicKey, verifyOpts, (err, decoded) => {
3032
if (err) {
3133
reject(err)
3234
}

src/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ const scheme = joi.object({
1111
realmUrl: joi.string().uri().required(),
1212
clientId: joi.string().min(1).required(),
1313
secret: joi.string().min(1),
14+
publicKey: joi.string().regex(/^-----BEGIN(?: RSA)? PUBLIC KEY-----[\s\S]*-----END(?: RSA)? PUBLIC KEY-----$/ig, 'PEM'),
15+
verifyOpts: joi.object().unknown(true),
1416
cache: joi.alternatives().try(joi.object({
1517
segment: joi.string().default('keycloakJwt')
1618
}), joi.boolean()).default(false),
1719
userInfo: joi.array().items(joi.string().min(1))
1820
})
1921
.xor('secret', 'publicKey')
2022
.without('secret', 'verifyOpts')
23+
.forbidden('verifyOpts.ignoreExpiration', 'verifyOpts.ignoreNotBefore')
2124
.required()
2225

2326
/**

0 commit comments

Comments
 (0)