Skip to content

Commit

Permalink
feat: add client_id to endSessionUrl query strings
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 19, 2022
1 parent 7c5f24a commit 6fd9350
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class BaseClient {
...{
post_logout_redirect_uri,
id_token_hint: hint,
client_id: this.client_id,
},
};

Expand Down
12 changes: 9 additions & 3 deletions test/client/client_instance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,18 @@ describe('Client', () => {
}).to.throw('end_session_endpoint must be configured on the issuer');
});

it('returns the end_session_endpoint only if nothing is passed', function () {
expect(this.client.endSessionUrl()).to.eql('https://op.example.com/session/end');
it('returns the end_session_endpoint with client_id if nothing is passed', function () {
expect(this.client.endSessionUrl()).to.eql(
'https://op.example.com/session/end?client_id=identifier',
);
expect(this.clientWithQuery.endSessionUrl()).to.eql(
'https://op.example.com/session/end?foo=bar',
'https://op.example.com/session/end?foo=bar&client_id=identifier',
);
});

it('defaults the post_logout_redirect_uri if client has some', function () {
expect(url.parse(this.clientWithUris.endSessionUrl(), true).query).to.eql({
client_id: 'identifier',
post_logout_redirect_uri: 'https://rp.example.com/logout/cb',
});
});
Expand All @@ -268,6 +271,7 @@ describe('Client', () => {
true,
).query,
).to.eql({
client_id: 'identifier',
id_token_hint: 'eyJhbGciOiJub25lIn0.eyJzdWIiOiJzdWJqZWN0In0.',
});
});
Expand Down Expand Up @@ -298,6 +302,7 @@ describe('Client', () => {
post_logout_redirect_uri: 'https://rp.example.com/logout/cb',
state: 'foo',
id_token_hint: 'idtoken',
client_id: 'identifier',
});
expect(
url.parse(
Expand All @@ -314,6 +319,7 @@ describe('Client', () => {
state: 'foo',
foo: 'bar',
id_token_hint: 'idtoken',
client_id: 'identifier',
});
});
});
Expand Down

0 comments on commit 6fd9350

Please sign in to comment.