From 054328364c72719e95f458cf3047e20e89fe4071 Mon Sep 17 00:00:00 2001 From: Jazz Grewal <39718912+jazzgrewal@users.noreply.github.com> Date: Wed, 30 Aug 2023 12:44:55 -0700 Subject: [PATCH] fixed the redirectSignOut using the env vars to dynamically create logout url (#75) * fixed the redirectSignOut using the env vars to dynamically create logout url * shorten the URL with variables * fix: poold and webclient ids fixes and add zone on docker compose --------- Co-authored-by: Derek Roberts Co-authored-by: Ricardo Campos --- docker-compose.yml | 5 +++-- frontend/src/aws-exports.js | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6249747d..590d0310 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,10 @@ version: '3.9' x-common: &common environment: - REACT_APP_USER_POOLS_ID: ca-central-1_t2HSZBHurS - REACT_APP_USER_POOLS_WEB_CLIENT_ID: 37798cpec8d4u1a2njt02nonp7 + REACT_APP_USER_POOLS_ID: ca-central-1_t2HSZBHur + REACT_APP_USER_POOLS_WEB_CLIENT_ID: 3g6n2ha1loi4kp1jhaq359vrvb REACT_APP_AWS_DOMAIN: prod-fam-user-pool-domain.auth.ca-central-1.amazoncognito.com + REACT_APP_ZONE: DEV healthcheck: test: [ "CMD-SHELL", "curl http://localhost:3000" ] interval: 15s diff --git a/frontend/src/aws-exports.js b/frontend/src/aws-exports.js index 22ccd8cc..9a39c83d 100644 --- a/frontend/src/aws-exports.js +++ b/frontend/src/aws-exports.js @@ -1,5 +1,10 @@ import { env } from './env'; +const ZONE = env.REACT_APP_ZONE.toLocaleLowerCase(); +const retUrl = window.location.origin; +const logoutDomain = `https://logon${ZONE === "prod"?'':'test'}7.gov.bc.ca/`; + + const awsconfig = { aws_cognito_region: env.REACT_APP_COGNITO_REGION || "ca-central-1", aws_user_pools_id: env.REACT_APP_USER_POOLS_ID, @@ -9,7 +14,7 @@ const awsconfig = { domain: env.REACT_APP_AWS_DOMAIN || "prod-fam-user-pool-domain.auth.ca-central-1.amazoncognito.com", scope: ['openid'], redirectSignIn: `${window.location.origin}/dashboard`, - redirectSignOut: env.REACT_APP_REDIRECT_SIGN_OUT || "https://logontest7.gov.bc.ca/clp-cgi/logoff.cgi?retnow=1&returl=https://dev.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/logout?redirect_uri=http://localhost:3000/", + redirectSignOut: env.REACT_APP_REDIRECT_SIGN_OUT || `${logoutDomain}/clp-cgi/logoff.cgi?retnow=1&returl=https://${ZONE}.loginproxy.gov.bc.ca/auth/realms/standard/protocol/openid-connect/logout?redirect_uri=${retUrl}/`, responseType: 'code', }, federationTarget: 'COGNITO_USER_POOLS',