Skip to content

Commit

Permalink
feat: allow multiple resource parameters in authorization requests
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Aug 24, 2019
1 parent a4e416a commit dfdd8cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ function authorizationParams(params) {
delete authParams[key];
} else if (key === 'claims' && typeof value === 'object') {
authParams[key] = JSON.stringify(value);
} else if (key === 'resource' && Array.isArray(value)) {
authParams[key] = value;
} else if (typeof value !== 'string') {
authParams[key] = String(value);
}
Expand Down
8 changes: 8 additions & 0 deletions test/client/client_instance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ describe('Client', () => {
});
});

it('allows resource to passed as an array', function () {
expect(url.parse(this.client.authorizationUrl({
resource: ['urn:example:com', 'urn:example-2:com'],
}), true).query).to.deep.contain({
resource: ['urn:example:com', 'urn:example-2:com'],
});
});

it('auto-stringifies claims parameter', function () {
expect(url.parse(this.client.authorizationUrl({
claims: { id_token: { email: null } },
Expand Down

0 comments on commit dfdd8cb

Please sign in to comment.