From 93f8c1ca6cd84205212a1c169247486c7cae850a Mon Sep 17 00:00:00 2001 From: Vinoth Kirubakaran Date: Mon, 6 Mar 2023 20:56:09 +0530 Subject: [PATCH 1/3] Update environment.ts Added new ENV variables for auth redirect paths --- packages/worker/src/environment.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/worker/src/environment.ts b/packages/worker/src/environment.ts index 3f762ea5ab..3509e0602c 100644 --- a/packages/worker/src/environment.ts +++ b/packages/worker/src/environment.ts @@ -66,6 +66,15 @@ const environment = { * Mock the email service in use - links to ethereal hosted emails are logged instead. */ ENABLE_EMAIL_TEST_MODE: process.env.ENABLE_EMAIL_TEST_MODE, + PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT: + process.env.PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT || "/", + PASSPORT_GOOGLEAUTH_FAILURE_REDIRECT: + process.env.PASSPORT_GOOGLEAUTH_FAILURE_REDIRECT || "/error", + PASSPORT_OIDCAUTH_SUCCESS_REDIRECT: + process.env.PASSPORT_OIDCAUTH_SUCCESS_REDIRECT || "/", + PASSPORT_OIDCAUTH_FAILURE_REDIRECT: + process.env.PASSPORT_OIDCAUTH_FAILURE_REDIRECT || "/error", + _set(key: any, value: any) { process.env[key] = value // @ts-ignore @@ -100,3 +109,4 @@ for (let [key, value] of Object.entries(environment)) { } export default environment + From 419cd1bff0c80ece8e5572a1eee50cdfa61ee8ed Mon Sep 17 00:00:00 2001 From: Vinoth Kirubakaran Date: Mon, 6 Mar 2023 20:57:24 +0530 Subject: [PATCH 2/3] Update auth.ts Updated success and error redirect paths using ENV variables --- .../worker/src/api/controllers/global/auth.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/worker/src/api/controllers/global/auth.ts b/packages/worker/src/api/controllers/global/auth.ts index 362723abd9..3327f7dc6d 100644 --- a/packages/worker/src/api/controllers/global/auth.ts +++ b/packages/worker/src/api/controllers/global/auth.ts @@ -204,13 +204,16 @@ export const googleCallback = async (ctx: any, next: any) => { return passport.authenticate( strategy, - { successRedirect: "/", failureRedirect: "/error" }, + { + successRedirect: env.PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT, + failureRedirect: env.PASSPORT_GOOGLEAUTH_FAILURE_REDIRECT, + }, async (err: any, user: SSOUser, info: any) => { await passportCallback(ctx, user, err, info) await context.identity.doInUserContext(user, ctx, async () => { await events.auth.login("google-internal", user.email) }) - ctx.redirect("/") + ctx.redirect(env.PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT) } )(ctx, next) } @@ -269,13 +272,17 @@ export const oidcCallback = async (ctx: any, next: any) => { return passport.authenticate( strategy, - { successRedirect: "/", failureRedirect: "/error" }, + { + successRedirect: env.PASSPORT_OIDCAUTH_SUCCESS_REDIRECT, + failureRedirect: env.PASSPORT_OIDCAUTH_FAILURE_REDIRECT, + }, async (err: any, user: SSOUser, info: any) => { await passportCallback(ctx, user, err, info) await context.identity.doInUserContext(user, ctx, async () => { await events.auth.login("oidc", user.email) }) - ctx.redirect("/") + ctx.redirect(env.PASSPORT_OIDCAUTH_SUCCESS_REDIRECT) } )(ctx, next) } + From 07778619b9a1a773a9f0dee93b4db59071939a7f Mon Sep 17 00:00:00 2001 From: Vinoth Kirubakaran Date: Mon, 6 Mar 2023 15:55:29 +0000 Subject: [PATCH 3/3] chore: ran prettier for environment.ts and auth.ts --- packages/worker/src/api/controllers/global/auth.ts | 1 - packages/worker/src/environment.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/worker/src/api/controllers/global/auth.ts b/packages/worker/src/api/controllers/global/auth.ts index 3327f7dc6d..1286fd519d 100644 --- a/packages/worker/src/api/controllers/global/auth.ts +++ b/packages/worker/src/api/controllers/global/auth.ts @@ -285,4 +285,3 @@ export const oidcCallback = async (ctx: any, next: any) => { } )(ctx, next) } - diff --git a/packages/worker/src/environment.ts b/packages/worker/src/environment.ts index 3509e0602c..812af6aacd 100644 --- a/packages/worker/src/environment.ts +++ b/packages/worker/src/environment.ts @@ -109,4 +109,3 @@ for (let [key, value] of Object.entries(environment)) { } export default environment -