Skip to content

Commit

Permalink
refactor: disable "token" including response types defaults
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the default enabled response types now omit all that
result in access tokens being issued by the authorization endpoint
and delivered via a fragment. If you're upgrading just configure
`responseTypes` to include the ones you need for legacy purposes.
  • Loading branch information
panva committed Jun 22, 2019
1 parent 2a5e15d commit 78e4ebb
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
1 change: 1 addition & 0 deletions certification/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ module.exports = {
},
],
},
responseTypes: ['code id_token token', 'code id_token', 'code token', 'code', 'id_token token', 'id_token', 'none'],
subjectTypes: ['public', 'pairwise'],
pairwiseIdentifier(ctx, accountId, { sectorIdentifier }) {
return crypto.createHash('sha256')
Expand Down
5 changes: 1 addition & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2489,18 +2489,15 @@ async renderError(ctx, out, error) {

### responseTypes

Array of response_type values that OP supports
Array of response_type values that OP supports. The default omits all response types that result in access tokens being issued by the authorization endpoint directly as per [OAuth 2.0 Security Best Current Practice](https://tools.ietf.org/html/draft-ietf-oauth-security-topics-12#section-3.1.2) You can still enable them if you need to.



_**default value**_:
```js
[
'code id_token token',
'code id_token',
'code token',
'code',
'id_token token',
'id_token',
'none'
]
Expand Down
8 changes: 4 additions & 4 deletions lib/helpers/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,10 @@ const DEFAULTS = {
/*
* responseTypes
*
* description: Array of response_type values that OP supports
* description: Array of response_type values that OP supports. The default omits all response
* types that result in access tokens being issued by the authorization endpoint directly as per
* [OAuth 2.0 Security Best Current Practice](https://tools.ietf.org/html/draft-ietf-oauth-security-topics-12#section-3.1.2)
* You can still enable them if you need to.
*
* example: Supported values list
* These are values defined in [Core 1.0](https://openid.net/specs/openid-connect-core-1_0.html#Authentication)
Expand All @@ -1289,11 +1292,8 @@ const DEFAULTS = {
* ```
*/
responseTypes: [
'code id_token token',
'code id_token',
'code token',
'code',
'id_token token',
'id_token',
'none',
],
Expand Down
15 changes: 11 additions & 4 deletions test/configuration/client_metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,16 +406,23 @@ describe('Client metadata validation', () => {
mustBeArray(this.title);
const responseTypes = ['code id_token token', 'code id_token', 'code token', 'code', 'id_token token', 'id_token', 'none'];
responseTypes.forEach((value) => {
const grants = [];
if (value.includes('token')) {
grants.push('implicit');
}
if (value.includes('code')) {
grants.push('authorization_code');
}
allows(this.title, [value], {
grant_types: ['implicit', 'authorization_code'],
});
grant_types: grants,
}, { responseTypes });
});
allows(this.title, responseTypes, {
grant_types: ['implicit', 'authorization_code'],
});
}, { responseTypes });
allows(this.title, ['token id_token'], { // mixed up order
grant_types: ['implicit'],
}, undefined, (client) => {
}, { responseTypes }, (client) => {
expect(client.metadata().response_types).to.eql(['id_token token']);
});

Expand Down
9 changes: 9 additions & 0 deletions test/default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,14 @@ module.exports = {
},
keys: ['foo'],
},
responseTypes: [
'code id_token token',
'code id_token',
'code token',
'code',
'id_token token',
'id_token',
'none',
],
whitelistedJWA: cloneDeep(JWA),
};

0 comments on commit 78e4ebb

Please sign in to comment.