Skip to content

Commit

Permalink
check the base URL of the signature domain when verifying allowed dom…
Browse files Browse the repository at this point in the history
…ains list
  • Loading branch information
eugenio-oddone committed Aug 3, 2023
1 parent c8e2649 commit 4d484ce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/get-jwks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ function buildGetJwks(options = {}) {
const { domain, alg, kid } = signature

const normalizedDomain = ensureTrailingSlash(domain)
const url = new URL(normalizedDomain)
const baseUrl = `${url.protocol}//${url.hostname}/`

if (allowedDomains.length && !allowedDomains.includes(normalizedDomain)) {
if (allowedDomains.length && !allowedDomains.includes(baseUrl)) {
const error = new GetJwksError(errorCode.DOMAIN_NOT_ALLOWED)
return Promise.reject(error)
}
Expand Down

0 comments on commit 4d484ce

Please sign in to comment.