Skip to content

Commit b9fe317

Browse files
committed
Fix handling of array aud values
1 parent 75e13b1 commit b9fe317

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ async function authenticate (options, cache, headers) {
191191
const aud = verifiedJWTs.current.raw.aud
192192
if (aud) {
193193
// aud can be a string or an array: https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3
194-
if (typeof aud === 'string' && !aud.startsWith(options.basePath)) throw new AuthenticationError('Invalid aud in JWT')
195-
if (!aud.some(audience => audience.startsWith(options.basePath))) throw new AuthenticationError('Invalid aud in JWT')
194+
if (typeof aud === 'string') {
195+
if (!aud.startsWith(options.basePath)) throw new AuthenticationError('Invalid aud in JWT')
196+
} else {
197+
if (!aud.some(audience => audience.startsWith(options.basePath))) throw new AuthenticationError('Invalid aud in JWT')
198+
}
196199
}
197200
}
198201

0 commit comments

Comments
 (0)