You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
Handle when aud OIDC claim is an Array (#4584)
* Handle when `aud` OIDC claim is an Array
The `aud` claim of OIDC id_tokens [can be an array](ce6d694639/src/Claims.ts (L92)
) but the existing logic
incorrectly assumes `aud` is always a string.
This PR adds the necessary check.
* Clarify `aud` OIDC claim check
* Fix for prettier
---------
Co-authored-by: David Baker <dbkr@users.noreply.github.com>
This commit is contained in:
@@ -179,7 +179,8 @@ export const validateIdToken = (
|
||||
* The ID Token MUST be rejected if the ID Token does not list the Client as a valid audience, or if it contains additional audiences not trusted by the Client.
|
||||
* EW: Don't accept tokens with other untrusted audiences
|
||||
* */
|
||||
if (claims.aud !== clientId) {
|
||||
const sanitisedAuds = typeof claims.aud === "string" ? [claims.aud] : claims.aud;
|
||||
if (!sanitisedAuds.includes(clientId)) {
|
||||
throw new Error("Invalid audience");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user