Skip to content

Commit

Permalink
fix: remove registration access token when client is deleted
Browse files Browse the repository at this point in the history
fixes #555
  • Loading branch information
panva committed Oct 22, 2019
1 parent 9e015e9 commit e24ad4a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/actions/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ module.exports = {
const { oidc: { provider } } = ctx;

await instance(provider).clientRemove(ctx.oidc.client.clientId);
await ctx.oidc.entities.RegistrationAccessToken.destroy();

ctx.status = 204;

Expand Down
8 changes: 6 additions & 2 deletions test/registration_management/registration_management.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,18 @@ describe('OAuth 2.0 Dynamic Client Registration Management Protocol', () => {
});

describe('Client Delete Request', () => {
it('responds w/ empty 204 and nocache headers', async function () {
it('responds w/ empty 204 and nocache headers and removes the registration access token', async function () {
const client = await setup.call(this, {});
return this.agent.del(`/reg/${client.client_id}`)
await this.agent.del(`/reg/${client.client_id}`)
.auth(client.registration_access_token, { type: 'bearer' })
.expect('pragma', 'no-cache')
.expect('cache-control', 'no-cache, no-store')
.expect('') // empty body
.expect(204);

expect(
await this.provider.RegistrationAccessToken.find(client.registration_access_token),
).to.be.undefined;
});

it('populates ctx.oidc.entities', function (done) {
Expand Down

0 comments on commit e24ad4a

Please sign in to comment.