Skip to content

Commit 7b3a8c6

Browse files
marie-dedikova-nhsankur-jain-nhs
authored andcommitted
VIA-591 MD/AS: Move AUTH_SECRET from lambda to SSM
(cherry picked from commit 9cbce0a)
1 parent dcac7d5 commit 7b3a8c6

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth(async () => {
3030
return await asyncLocalStorage.run(requestContext, async () => {
3131
return {
3232
providers: [await NHSLoginAuthProvider()],
33+
secret: config.AUTH_SECRET,
3334
pages: {
3435
signIn: SSO_FAILURE_ROUTE,
3536
signOut: SESSION_LOGOUT_ROUTE,

infrastructure/environments/dev/locals.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ locals {
4343
IS_APIM_AUTH_ENABLED = false
4444

4545
AUTH_TRUST_HOST = "true"
46-
AUTH_SECRET = random_password.auth_secret.result
4746
APP_VERSION = local.app_version
4847

4948
NBS_URL = "https://f.nhswebsite-integration.nhs.uk/nbs"
@@ -60,12 +59,6 @@ locals {
6059
}
6160
}
6261

63-
resource "random_password" "auth_secret" {
64-
length = 64
65-
special = true
66-
override_special = "/+"
67-
}
68-
6962
resource "null_resource" "check_workspace" {
7063
lifecycle {
7164
precondition {

infrastructure/environments/dev/ssm.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,16 @@ resource "aws_ssm_parameter" "apim_private_key" {
3232
value_wo = "to-be-replaced-manually"
3333
value_wo_version = 0
3434
}
35+
36+
resource "aws_ssm_parameter" "auth_secret" {
37+
name = "/${local.prefix}/AUTH_SECRET"
38+
type = "SecureString"
39+
value_wo = random_password.auth_secret.result
40+
value_wo_version = 0
41+
}
42+
43+
resource "random_password" "auth_secret" {
44+
length = 64
45+
special = true
46+
override_special = "/+"
47+
}

0 commit comments

Comments
 (0)