From 1bd22a8a48bfbcd073ce5a85d9582edbc5c5f3ea Mon Sep 17 00:00:00 2001 From: Ulysse Carion Date: Thu, 16 May 2024 16:05:30 -0700 Subject: [PATCH] add required domains for apps --- src/lib/store.ts | 1 + src/pages/InstantSetupPage.tsx | 2 ++ src/pages/SSOPage.tsx | 22 ++++++++-------------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/lib/store.ts b/src/lib/store.ts index 5bb1bb6..7103f73 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -8,6 +8,7 @@ interface App { id: string; spAcsUrl: string; spEntityId: string; + requiredDomain: string; } export function useStore(): [StoreData, (_: StoreData) => void] { diff --git a/src/pages/InstantSetupPage.tsx b/src/pages/InstantSetupPage.tsx index d34ac35..51afafc 100644 --- a/src/pages/InstantSetupPage.tsx +++ b/src/pages/InstantSetupPage.tsx @@ -10,6 +10,7 @@ export function InstantSetupPage() { const appId = searchParams.get("appId")!; const spAcsUrl = searchParams.get("spAcsUrl")!; const spEntityId = searchParams.get("spEntityId")!; + const requiredDomain = searchParams.get("requiredDomain")!; const email = searchParams.get("email")!; const firstName = searchParams.get("firstName")!; const lastName = searchParams.get("lastName")!; @@ -24,6 +25,7 @@ export function InstantSetupPage() { id: appId, spAcsUrl, spEntityId, + requiredDomain, }, }, }); diff --git a/src/pages/SSOPage.tsx b/src/pages/SSOPage.tsx index f477800..b2e3789 100644 --- a/src/pages/SSOPage.tsx +++ b/src/pages/SSOPage.tsx @@ -29,7 +29,7 @@ import moment from "moment"; import { clsx } from "clsx"; const formSchema = z.object({ - email: z.string().email({ message: "Email must be a well-formed email." }), + email: z.string().min(1, { message: "Email is required." }), firstName: z.string(), lastName: z.string(), }); @@ -98,7 +98,7 @@ export function SSOPage() { inputRef.current!.value = await encodeAssertion(key, { idpEntityId: `https://dummyidp.com/apps/${app.id}`, - subjectId: values.email, + subjectId: `${values.email}@${app.requiredDomain}`, firstName: values.firstName, lastName: values.lastName, spEntityId: app.spEntityId, @@ -138,20 +138,14 @@ export function SSOPage() { Email - +
+ + + @{app.requiredDomain} + +
- {email && ( - - You'll want to keep this as a{" "} - - {email.split("@")[1]} - {" "} - email address, otherwise your login will probably be - rejected by {new URL(app.spAcsUrl).hostname}. - - )} -
)}