Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(authentication): Remove entity from connection information on logout #1889

Merged
merged 2 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/authentication/src/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export class JWTStrategy extends AuthenticationBaseStrategy {
} else if (event === 'disconnect' || isValidLogout) {
debug('Removing authentication information and expiration timer from connection');

const { entity } = this.configuration;

delete connection[entity];
delete connection.authentication;

lt.clearTimeout(this.expirationTimers.get(connection));
this.expirationTimers.delete(connection);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/authentication/test/jwt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('authentication/jwt', () => {
});
});

it('sends disconnect event when connection token expires and removes authentication', async () => {
it('sends disconnect event when connection token expires and removes all connection information', async () => {
const connection: any = {};
const token: string = await app.service('authentication').createAccessToken({}, {
subject: `${user.id}`,
Expand All @@ -129,6 +129,8 @@ describe('authentication/jwt', () => {
assert.strictEqual(disconnection, connection);

assert.ok(!connection.authentication);
assert.ok(!connection.user);
assert.strictEqual(Object.keys(connection).length, 0);
});

it('deletes authentication information on remove', async () => {
Expand All @@ -147,6 +149,7 @@ describe('authentication/jwt', () => {
});

assert.ok(!connection.authentication);
assert.ok(!connection.user);
});

it('does not remove if accessToken does not match', async () => {
Expand Down