Skip to content

Commit

Permalink
Merge pull request #50 from Authress/filter-jwks-kid
Browse files Browse the repository at this point in the history
Optimize for filtering by kid in query string.
  • Loading branch information
wparad authored Sep 27, 2024
2 parents f6edabd + 7649e57 commit 34a3364
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tokenVerifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function getPublicKey(httpClient, jwkKeyListUrl, kid) {
return jwk;
}

throw new TokenVerificationError('No matching public key found for token');
throw new TokenVerificationError('The Service Client Access Key is not valid yet or has been deleted. For new Access Keys just created, key validation is cached and can take up to 5 minutes before new keys can be used.');
};

if (!keyMap[hashKey]) {
Expand Down Expand Up @@ -109,7 +109,7 @@ module.exports = async function(authressCustomDomainOrHttpClient, requestToken,
throw new TokenVerificationError(`Unauthorized: Invalid Sub found for service client token: ${unverifiedToken.payload.sub}`);
}

const key = options.expectedPublicKey || await getPublicKey(httpClient, `${issuer}/.well-known/openid-configuration/jwks`, kid);
const key = options.expectedPublicKey || await getPublicKey(httpClient, `${issuer}/.well-known/openid-configuration/jwks?kid=${kid}`, kid);

try {
const verifiedToken = await jwtVerify(authenticationToken, await importJWK(key), { algorithms: ['EdDSA', 'RS512'], issuer, ...options.verifierOptions });
Expand Down

0 comments on commit 34a3364

Please sign in to comment.