From 4bf7c6298379e3c7a1159a7ce727498901f4d67d Mon Sep 17 00:00:00 2001 From: Kiran Date: Tue, 31 Jan 2023 18:36:35 +0530 Subject: [PATCH 1/4] initiate the SAML authentication flow directly --- apps/web/pages/auth/saml.tsx | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 apps/web/pages/auth/saml.tsx diff --git a/apps/web/pages/auth/saml.tsx b/apps/web/pages/auth/saml.tsx new file mode 100644 index 00000000000000..d8282c228d4fff --- /dev/null +++ b/apps/web/pages/auth/saml.tsx @@ -0,0 +1,37 @@ +import { signIn } from "next-auth/react"; +import { useRouter } from "next/router"; + +import { samlProductID, samlTenantID } from "@calcom/features/ee/sso/lib/saml"; +import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants"; + +import { inferSSRProps } from "@lib/types/inferSSRProps"; + +// This page is used to initiate the SAML authentication flow by redirecting to the SAML provider. +// Accessible only on self-hosted Cal.com instances. +export default function Page({ samlTenantID, samlProductID }: inferSSRProps) { + const router = useRouter(); + + if (HOSTED_CAL_FEATURES) { + router.push("/auth/login"); + } + + // Initiate SAML authentication flow + signIn( + "saml", + { + callbackUrl: "/", + }, + { tenant: samlTenantID, product: samlProductID } + ); + + return null; +} + +export async function getServerSideProps() { + return { + props: { + samlTenantID, + samlProductID, + }, + }; +} From 7bcbf7ede81efc30fb3ce6fc76ae4b6f1293b342 Mon Sep 17 00:00:00 2001 From: Kiran Date: Tue, 31 Jan 2023 18:37:21 +0530 Subject: [PATCH 2/4] tweaks --- apps/web/pages/auth/saml.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/web/pages/auth/saml.tsx b/apps/web/pages/auth/saml.tsx index d8282c228d4fff..c4afc08e5c312a 100644 --- a/apps/web/pages/auth/saml.tsx +++ b/apps/web/pages/auth/saml.tsx @@ -13,6 +13,7 @@ export default function Page({ samlTenantID, samlProductID }: inferSSRProps Date: Tue, 31 Jan 2023 19:01:47 +0530 Subject: [PATCH 3/4] update the route --- apps/web/pages/auth/{saml.tsx => sso/direct.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename apps/web/pages/auth/{saml.tsx => sso/direct.tsx} (100%) diff --git a/apps/web/pages/auth/saml.tsx b/apps/web/pages/auth/sso/direct.tsx similarity index 100% rename from apps/web/pages/auth/saml.tsx rename to apps/web/pages/auth/sso/direct.tsx From a6be3296b86285d5febba4929cd3470a85e0ae0d Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 7 Mar 2023 18:10:28 +0000 Subject: [PATCH 4/4] Update apps/web/pages/auth/sso/direct.tsx Fix lint --- apps/web/pages/auth/sso/direct.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/pages/auth/sso/direct.tsx b/apps/web/pages/auth/sso/direct.tsx index c4afc08e5c312a..23b0a66be4ace5 100644 --- a/apps/web/pages/auth/sso/direct.tsx +++ b/apps/web/pages/auth/sso/direct.tsx @@ -4,7 +4,7 @@ import { useRouter } from "next/router"; import { samlProductID, samlTenantID } from "@calcom/features/ee/sso/lib/saml"; import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants"; -import { inferSSRProps } from "@lib/types/inferSSRProps"; +import type { inferSSRProps } from "@lib/types/inferSSRProps"; // This page is used to initiate the SAML authentication flow by redirecting to the SAML provider. // Accessible only on self-hosted Cal.com instances.