From 70710c0fa3a51dbcdc202e68b8560b4c7a854d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=B8rl=C3=BCck=20Berg?= <36937807+henrikhorluck@users.noreply.github.com> Date: Sat, 24 Feb 2024 17:02:56 +0100 Subject: [PATCH] Sync env names with doppler --- next.config.js | 6 ++++-- src/authentication/api/settings.ts | 13 +++++-------- src/common/constants/endpoints.ts | 4 +++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/next.config.js b/next.config.js index f4fa4001..583a7108 100644 --- a/next.config.js +++ b/next.config.js @@ -67,13 +67,15 @@ module.exports = withBundleAnalyzer( return config; }, env: { + HOSTNAME: process.env.HOSTNAME || "localhost", + PORT: process.env.PORT || "8000", OW4_ADDRESS: process.env.OW4_ADDRESS || 'https://old.online.ntnu.no', - OW4_SSO_CLIENT_ID: process.env.OW4_SSO_CLIENT_ID || '', + AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || '', OW4_SSO_CALLBACK: process.env.OW4_SSO_CALLBACK || 'http://localhost:8080/authentication/callback', OWF_SENTRY_DSN: process.env.OWF_SENTRY_DSN || '', OWF_GOOGLE_ANALYTICS_KEY: process.env.OWF_GOOGLE_ANALYTICS_KEY || '', OWF_VAPID_SERVER_KEY: process.env.OWF_VAPID_SERVER_KEY || '', - OWF_AUTH_DOMAIN: process.env.OWF_AUTH_DOMAIN || '', + AUTH0_ISSUER: process.env.AUTH0_ISSUER || '', STRIPE_PUBLIC_KEY_ARRKOM: process.env.STRIPE_PUBLIC_KEY_ARRKOM || null, STRIPE_PUBLIC_KEY_FAGKOM: process.env.STRIPE_PUBLIC_KEY_FAGKOM || null, STRIPE_PUBLIC_KEY_PROKOM: process.env.STRIPE_PUBLIC_KEY_PROKOM || null, diff --git a/src/authentication/api/settings.ts b/src/authentication/api/settings.ts index 861b81ce..f99bc3b4 100644 --- a/src/authentication/api/settings.ts +++ b/src/authentication/api/settings.ts @@ -1,18 +1,15 @@ -import { AUTH_DOMAIN, DOMAIN } from 'common/constants/endpoints'; +import { HOST } from 'common/constants/endpoints'; import { UserManagerSettings } from 'oidc-client-ts'; const settings: UserManagerSettings = { - authority: AUTH_DOMAIN, - client_id: process.env.OW4_SSO_CLIENT_ID || '', + authority: process.env.AUTH0_ISSUER || '', + client_id: process.env.AUTH0_CLIENT_ID || '', redirect_uri: process.env.OW4_SSO_CALLBACK || '', - post_logout_redirect_uri: DOMAIN + '/', - scope: 'openid profile onlineweb4 email', + post_logout_redirect_uri: HOST, + scope: 'openid profile email', automaticSilentRenew: true, filterProtocolClaims: true, loadUserInfo: true, - extraQueryParams: { - audience: 'https://online.ntnu.no', - }, revokeTokensOnSignout: true, revokeTokenTypes: ['refresh_token'], }; diff --git a/src/common/constants/endpoints.ts b/src/common/constants/endpoints.ts index 9fa964c6..0260de78 100644 --- a/src/common/constants/endpoints.ts +++ b/src/common/constants/endpoints.ts @@ -1,5 +1,7 @@ export const DOMAIN = process.env.OW4_ADDRESS || ''; -export const AUTH_DOMAIN = process.env.OWF_AUTH_DOMAIN || ''; +export const HOST = process.env.NODE_ENV === "production" + ? `https://${process.env.HOSTNAME}` + : `http://${process.env.HOSTNAME}:${process.env.PORT}`; export const AUTH = DOMAIN + '/api/v1/sso/openid/'; export const EVENTS = DOMAIN + '/api/v1/events/';