Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/javascript/openproof.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const decodeJsonPart = value => {
}
};
const audienceMatches = (claims, clientId) => {
if (claims.azp !== undefined && claims.azp !== clientId) return false;
if (typeof claims.aud === 'string') return claims.aud === clientId;
if (!Array.isArray(claims.aud) || !claims.aud.every(value => typeof value === 'string')
|| !claims.aud.includes(clientId)) return false;
Expand Down
13 changes: 13 additions & 0 deletions sdk/javascript/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ const accepted = await client.handleCallback(callback(valid.state));
assert.equal(accepted.id_token_claims.sub, 'identity-42');
assert.equal(storage.has(`openproof:${valid.state}`), false);

const authorizedParty = await begin();
tokenResponse = {
access_token: 'access-token',
id_token: await signIdToken(claims(authorizedParty.nonce, {
aud: [clientId, 'other-client'], azp: clientId,
})),
};
const acceptedAzp = await client.handleCallback(callback(authorizedParty.state));
assert.equal(acceptedAzp.id_token_claims.azp, clientId);

const issuerMismatch = await begin();
await assert.rejects(
client.handleCallback(
Expand Down Expand Up @@ -120,6 +130,9 @@ for (const override of [
{ iss: 'https://evil.example' },
{ aud: 'other-client' },
{ aud: [clientId, 'other-client'] },
{ azp: 'other-client' },
{ aud: [clientId], azp: 'other-client' },
{ aud: [clientId, 'other-client'], azp: 'other-client' },
{ iat: Math.floor(Date.now() / 1000) + 600 },
{ at_hash: 'invalid-access-token-hash' },
]) {
Expand Down
Loading