Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL to initiate SAML authentication flow #6813

Merged
merged 5 commits into from
Mar 7, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions apps/web/pages/auth/sso/direct.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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";
emrysal marked this conversation as resolved.
Show resolved Hide resolved

// 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<typeof getServerSideProps>) {
const router = useRouter();

if (HOSTED_CAL_FEATURES) {
router.push("/auth/login");
return;
}

// Initiate SAML authentication flow
signIn(
"saml",
{
callbackUrl: "/",
},
{ tenant: samlTenantID, product: samlProductID }
);

return null;
}

export async function getServerSideProps() {
return {
props: {
samlTenantID,
samlProductID,
},
};
}