From 12474dbaaaf914d9bb2b314a616d7b3ba1e2b471 Mon Sep 17 00:00:00 2001 From: Tom Ridd Date: Tue, 20 Feb 2024 08:30:12 +0000 Subject: [PATCH] Bugfix/auth server api change (#71) * update api calls for server-side enum change to snake case * update version of debian * linter errors * simplify grantType --- Dockerfile | 2 +- package.json | 3 ++- server/mappers/baseClientApi/addBaseClient.ts | 3 +-- server/mappers/baseClientApi/getBaseClient.ts | 4 +--- server/mappers/baseClientApi/updateBaseClient.ts | 3 +-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03e108b1..da11362d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Stage: base image -FROM node:20.11-bullseye-slim as base +FROM node:20.11-bookworm-slim as base ARG BUILD_NUMBER ARG GIT_REF diff --git a/package.json b/package.json index 17e5a440..89b84df1 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "security_audit": "npx audit-ci --config audit-ci.json", "int-test": "cypress run --config video=false", "int-test-ui": "cypress open --e2e --browser chrome", - "clean": "rm -rf dist build node_modules stylesheets" + "clean": "rm -rf dist build node_modules stylesheets", + "rebuild": "npm run clean && npm i && npm run build" }, "engines": { "node": "^20", diff --git a/server/mappers/baseClientApi/addBaseClient.ts b/server/mappers/baseClientApi/addBaseClient.ts index 45daca56..f65f3a56 100644 --- a/server/mappers/baseClientApi/addBaseClient.ts +++ b/server/mappers/baseClientApi/addBaseClient.ts @@ -1,7 +1,6 @@ import { BaseClient } from '../../interfaces/baseClientApi/baseClient' import { AddBaseClientRequest } from '../../interfaces/baseClientApi/baseClientRequestBody' import { daysRemaining } from '../../utils/utils' -import { GrantTypes } from '../../data/enums/grantTypes' export default (baseClient: BaseClient): AddBaseClientRequest => { return { @@ -13,7 +12,7 @@ export default (baseClient: BaseClient): AddBaseClientRequest => { databaseUserName: baseClient.clientCredentials.databaseUserName, validDays: baseClient.config.expiryDate ? daysRemaining(baseClient.config.expiryDate) : null, accessTokenValidityMinutes: baseClient.accessTokenValidity ? baseClient.accessTokenValidity / 60 : null, - grantType: baseClient.grantType === GrantTypes.ClientCredentials ? 'CLIENT_CREDENTIALS' : 'AUTHORIZATION_CODE', + grantType: baseClient.grantType, mfa: baseClient.authorisationCode.mfa, mfaRememberMe: baseClient.authorisationCode.mfaRememberMe, jwtFields: baseClient.authorisationCode.jwtFields, diff --git a/server/mappers/baseClientApi/getBaseClient.ts b/server/mappers/baseClientApi/getBaseClient.ts index 8815bed2..50e6cf1e 100644 --- a/server/mappers/baseClientApi/getBaseClient.ts +++ b/server/mappers/baseClientApi/getBaseClient.ts @@ -1,6 +1,5 @@ import { GetBaseClientResponse } from '../../interfaces/baseClientApi/baseClientResponse' import { BaseClient, DeploymentDetails } from '../../interfaces/baseClientApi/baseClient' -import { GrantTypes } from '../../data/enums/grantTypes' import { ClientType } from '../../data/enums/clientTypes' import { HostingType } from '../../data/enums/hostingTypes' import { snake } from '../../utils/utils' @@ -10,8 +9,7 @@ export default (response: GetBaseClientResponse): BaseClient => { baseClientId: response.clientId, accessTokenValidity: response.accessTokenValidityMinutes ? response.accessTokenValidityMinutes * 60 : 0, scopes: response.scopes ? response.scopes : [], - grantType: - response.grantType === 'CLIENT_CREDENTIALS' ? GrantTypes.ClientCredentials : GrantTypes.AuthorizationCode, + grantType: snake(response.grantType), audit: response.jiraNumber ? response.jiraNumber : '', count: 1, clientCredentials: { diff --git a/server/mappers/baseClientApi/updateBaseClient.ts b/server/mappers/baseClientApi/updateBaseClient.ts index 6e9f5f9b..775120a9 100644 --- a/server/mappers/baseClientApi/updateBaseClient.ts +++ b/server/mappers/baseClientApi/updateBaseClient.ts @@ -1,7 +1,6 @@ import { BaseClient } from '../../interfaces/baseClientApi/baseClient' import { UpdateBaseClientRequest } from '../../interfaces/baseClientApi/baseClientRequestBody' import { daysRemaining } from '../../utils/utils' -import { GrantTypes } from '../../data/enums/grantTypes' export default (baseClient: BaseClient): UpdateBaseClientRequest => { return { @@ -12,7 +11,7 @@ export default (baseClient: BaseClient): UpdateBaseClientRequest => { databaseUserName: baseClient.clientCredentials.databaseUserName, validDays: baseClient.config.expiryDate ? daysRemaining(baseClient.config.expiryDate) : null, accessTokenValidityMinutes: baseClient.accessTokenValidity ? baseClient.accessTokenValidity / 60 : null, - grantType: baseClient.grantType === GrantTypes.ClientCredentials ? 'CLIENT_CREDENTIALS' : 'AUTHORIZATION_CODE', + grantType: baseClient.grantType, mfa: baseClient.authorisationCode.mfa, mfaRememberMe: baseClient.authorisationCode.mfaRememberMe, jwtFields: baseClient.authorisationCode.jwtFields,