Skip to content

Commit

Permalink
fix(DPoP,mTLS): reject client configuration in which binding is requi…
Browse files Browse the repository at this point in the history
…red but response types include an implicit token response
  • Loading branch information
panva committed Mar 26, 2024
1 parent 1b073c0 commit cd7e0f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/helpers/client_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,18 @@ export default function getSchema(provider) {
}

{
const { length } = [
this.tls_client_certificate_bound_access_tokens,
this.dpop_bound_access_tokens,
].filter(Boolean);
const { 0: pop, length } = [
'tls_client_certificate_bound_access_tokens',
'dpop_bound_access_tokens',
].filter((conf) => this[conf]);

if (length > 1) {
this.invalidate('only one proof of possession mechanism can be made required at a time');
}

if (length !== 0 && responseTypes.includes('token')) {
this.invalidate(`response_types must not include "token" when ${pop} is used`);
}
}

{
Expand Down
4 changes: 4 additions & 0 deletions test/configuration/client_metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,7 @@ describe('Client metadata validation', () => {
enabled: true,
},
},
responseTypes: ['code', 'code token'],
};
mustBeBoolean(this.title, undefined, configuration);
mustBeBoolean(this.title, undefined, configuration);
Expand All @@ -1562,6 +1563,7 @@ describe('Client metadata validation', () => {
...configuration,
clientDefaults: { dpop_bound_access_tokens: true },
});
rejects(this.title, true, 'response_types must not include "token" when dpop_bound_access_tokens is used', { grant_types: ['authorization_code', 'implicit'], response_types: ['code', 'code token'] }, configuration);
});
});

Expand Down Expand Up @@ -1842,11 +1844,13 @@ describe('Client metadata validation', () => {
features: {
mTLS: { enabled: true, certificateBoundAccessTokens: true },
},
responseTypes: ['code', 'code token'],
};

defaultsTo(this.title, false, undefined, configuration);
defaultsTo(this.title, undefined);
mustBeBoolean(this.title, undefined, configuration);
rejects(this.title, true, 'response_types must not include "token" when tls_client_certificate_bound_access_tokens is used', { grant_types: ['authorization_code', 'implicit'], response_types: ['code', 'code token'] }, configuration);
});
});

Expand Down

0 comments on commit cd7e0f4

Please sign in to comment.