diff --git a/packages/agent/src/agent/routes/security/authentication.ts b/packages/agent/src/agent/routes/security/authentication.ts index 7430798135..8cbd77c120 100644 --- a/packages/agent/src/agent/routes/security/authentication.ts +++ b/packages/agent/src/agent/routes/security/authentication.ts @@ -6,7 +6,7 @@ import jsonwebtoken from 'jsonwebtoken'; import jwt from 'koa-jwt'; import { Context } from 'koa'; -import { HttpCode, RouteType } from '../../types'; +import { RouteType } from '../../types'; import BaseRoute from '../base-route'; import ForestHttpApi from '../../utils/forest-http-api'; @@ -44,13 +44,11 @@ export default class Authentication extends BaseRoute { router.get('/authentication/callback', this.handleAuthenticationCallback.bind(this)); router.use(jwt({ secret: this.options.authSecret, cookie: 'forest_session_token' })); - - router.post('/authentication/logout', this.handleAuthenticationLogout.bind(this)); } public async handleAuthentication(context: Context): Promise { const renderingId = Number(context.request.body?.renderingId); - this.checkRenderingId(renderingId); + Authentication.checkRenderingId(renderingId); const authorizationUrl = this.client.authorizationUrl({ scope: 'openid email profile', @@ -68,7 +66,7 @@ export default class Authentication extends BaseRoute { try { renderingId = JSON.parse(state).renderingId; - this.checkRenderingId(renderingId); + Authentication.checkRenderingId(renderingId); } catch { throw new ValidationError('Failed to retrieve renderingId from query[state]'); } @@ -87,11 +85,7 @@ export default class Authentication extends BaseRoute { }; } - public async handleAuthenticationLogout(context: Context) { - context.response.status = HttpCode.NoContent; - } - - private checkRenderingId(renderingId: number): void { + private static checkRenderingId(renderingId: number): void { if (Number.isNaN(renderingId)) { throw new ValidationError('Rendering id must be a number'); } diff --git a/packages/agent/test/agent/routes/security/authentication.test.ts b/packages/agent/test/agent/routes/security/authentication.test.ts index d9518264d9..a8a3235099 100644 --- a/packages/agent/test/agent/routes/security/authentication.test.ts +++ b/packages/agent/test/agent/routes/security/authentication.test.ts @@ -2,7 +2,6 @@ import { createMockContext } from '@shopify/jest-koa-mocks'; import openidClient, { Issuer } from 'openid-client'; import * as factories from '../../__factories__'; -import { HttpCode } from '../../../../src/agent/types'; import Authentication from '../../../../src/agent/routes/security/authentication'; import ForestHttpApi from '../../../../src/agent/utils/forest-http-api'; @@ -121,7 +120,6 @@ describe('Authentication', () => { expect(router.post).toHaveBeenCalledWith('/authentication', expect.any(Function)); expect(router.get).toHaveBeenCalledWith('/authentication/callback', expect.any(Function)); - expect(router.post).toHaveBeenCalledWith('/authentication/logout', expect.any(Function)); }); }); }); @@ -240,16 +238,4 @@ describe('Authentication', () => { }); }); }); - - describe('handleAuthenticationLogout', () => { - test('should return a 204', async () => { - const authentication = new Authentication(services, options); - - const context = createMockContext(); - - await authentication.handleAuthenticationLogout(context); - - expect(context.response.status).toEqual(HttpCode.NoContent); - }); - }); });