From 9ba39e99c6ef9662310796ddc5323dec904138bc Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 30 Sep 2024 07:03:02 -0700 Subject: [PATCH 1/4] feature: add region select to login/signup and improve login layout --- .../components/signup/InitialSignupStep.tsx | 2 + frontend/src/pages/_app.tsx | 18 ++- .../components/InitialStep/InitialStep.tsx | 140 ++++++++++-------- 3 files changed, 87 insertions(+), 73 deletions(-) diff --git a/frontend/src/components/signup/InitialSignupStep.tsx b/frontend/src/components/signup/InitialSignupStep.tsx index 3a7c6db04..fd63f33f0 100644 --- a/frontend/src/components/signup/InitialSignupStep.tsx +++ b/frontend/src/components/signup/InitialSignupStep.tsx @@ -4,6 +4,7 @@ import { faGithub, faGitlab, faGoogle } from "@fortawesome/free-brands-svg-icons import { faEnvelope } from "@fortawesome/free-regular-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { RegionSelect } from "@app/components/navigation/RegionSelect"; import { useServerConfig } from "@app/context"; import { LoginMethod } from "@app/hooks/api/admin/types"; @@ -25,6 +26,7 @@ export default function InitialSignupStep({

{t("signup.initial-title")}

+ {shouldDisplaySignupMethod(LoginMethod.GOOGLE) && (
-
- )} - {shouldDisplayLoginMethod(LoginMethod.GITHUB) && ( -
- -
- )} - {shouldDisplayLoginMethod(LoginMethod.GITLAB) && ( -
- -
- )} + {shouldDisplayLoginMethod(LoginMethod.SAML) && ( -
+
)} +
+ {shouldDisplayLoginMethod(LoginMethod.GOOGLE) && ( + + { + const callbackPort = queryParams.get("callback_port"); + + window.open( + `/api/v1/sso/redirect/google${ + callbackPort ? `?callback_port=${callbackPort}` : "" + }` + ); + window.close(); + }} + className="h-10 w-full bg-mineshaft-600" + > + + + + )} + {shouldDisplayLoginMethod(LoginMethod.GITHUB) && ( + + { + const callbackPort = queryParams.get("callback_port"); + + window.open( + `/api/v1/sso/redirect/github${ + callbackPort ? `?callback_port=${callbackPort}` : "" + }` + ); + + window.close(); + }} + className="h-10 w-full bg-mineshaft-600" + > + + + + )} + {shouldDisplayLoginMethod(LoginMethod.GITLAB) && ( + + { + const callbackPort = queryParams.get("callback_port"); + + window.open( + `/api/v1/sso/redirect/gitlab${ + callbackPort ? `?callback_port=${callbackPort}` : "" + }` + ); + + window.close(); + }} + className="h-10 w-full bg-mineshaft-600" + > + + + + )} +
{(!config.enabledLoginMethods || (shouldDisplayLoginMethod(LoginMethod.EMAIL) && config.enabledLoginMethods.length > 1)) && (
@@ -316,7 +326,7 @@ export const InitialStep = ({ setStep, email, setEmail, password, setPassword }: />
)} -
+
+ + + {regions.map(({ value, label, location, flag }) => ( +
+

+ {flag} + {value.toUpperCase()} Region +

+
    +
  • + Fastest + option if you are based in {value === Region.US ? "the" : ""} {label} +
  • +
  • + Data + storage compliance for this region +
  • +
  • + Hosted + in {location} +
  • +
+
+ ))} +
+ +
+ ); +}; From 2fa30bdd0ee61dc1a4882bcc5f3f22a733fb8ed7 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 30 Sep 2024 07:08:33 -0700 Subject: [PATCH 3/4] improvement: add info about migrating regions --- frontend/src/components/navigation/RegionSelect.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/navigation/RegionSelect.tsx b/frontend/src/components/navigation/RegionSelect.tsx index 54b393d1b..21bc26a56 100644 --- a/frontend/src/components/navigation/RegionSelect.tsx +++ b/frontend/src/components/navigation/RegionSelect.tsx @@ -110,7 +110,7 @@ export const RegionSelect = () => { {regions.map(({ value, label, location, flag }) => (
From 70aa73482e5b30f96af6ecd08941745a376f049b Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Mon, 30 Sep 2024 09:58:49 -0700 Subject: [PATCH 4/4] fix: only display region select for cloud --- frontend/src/components/navigation/RegionSelect.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/navigation/RegionSelect.tsx b/frontend/src/components/navigation/RegionSelect.tsx index 21bc26a56..008c7ea3a 100644 --- a/frontend/src/components/navigation/RegionSelect.tsx +++ b/frontend/src/components/navigation/RegionSelect.tsx @@ -80,8 +80,8 @@ export const RegionSelect = () => { const [subdomain, domain] = window.location.host.split("."); - // only display region select for local dev and cloud - if (!(subdomain.match(/localhost:8080/) || domain.match(/infisical/))) return null; + // only display region select for cloud + if (!domain?.match(/infisical/)) return null; // default to US if not eu const currentRegion = subdomain === Region.EU ? regions[1] : regions[0];