Reintroduce SAML SSO (#4938)
* wip reintroduce SAML SSO * Fix the imports * wip * Some tweaks * Fix the type * Reduce the textarea height * Cleanup * Fix the access issues * Make the SAML SSO active on the sidebar * Add SP's instructions * Remove the console.log * Add the condition to check SAML SSO is enabled * Replace SAML SSO with Single Sign-On * Update to SAML feature * Upgrade the @boxyhq/saml-jackson * Fix the SAML part and other cleanup * Tweaks to SAML SSO setup * Fix the type * Fix the import path * Remove samlLoginUrl * Import fixes * Simplifies endpoints Co-authored-by: zomars <[email protected]>
This commit is contained in:
1 parent
41689ecc92
commit
759a89bb0c
27 files changed
+990
-1017
No files matched your search
@@ -1,164 +0,0 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import showToast from "@calcom/lib/notification";
|
||||
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Alert } from "@calcom/ui/Alert";
|
||||
import Badge from "@calcom/ui/Badge";
|
||||
import Button from "@calcom/ui/Button";
|
||||
import ConfirmationDialogContent from "@calcom/ui/ConfirmationDialogContent";
|
||||
import { Dialog, DialogTrigger } from "@calcom/ui/Dialog";
|
||||
import { TextArea } from "@calcom/ui/form/fields";
|
||||
|
||||
import LicenseRequired from "./LicenseRequired";
|
||||
|
||||
export default function SAMLConfiguration({
|
||||
teamsView,
|
||||
teamId,
|
||||
}: {
|
||||
teamsView: boolean;
|
||||
teamId: null | undefined | number;
|
||||
}) {
|
||||
const [isSAMLLoginEnabled, setIsSAMLLoginEnabled] = useState(false);
|
||||
const [samlConfig, setSAMLConfig] = useState<string | null>(null);
|
||||
|
||||
const query = trpc.useQuery(["viewer.showSAMLView", { teamsView, teamId }]);
|
||||
|
||||
const telemetry = useTelemetry();
|
||||
|
||||
useEffect(() => {
|
||||
const data = query.data;
|
||||
setIsSAMLLoginEnabled(data?.isSAMLLoginEnabled ?? false);
|
||||
setSAMLConfig(data?.provider ?? null);
|
||||
}, [query.data]);
|
||||
|
||||
const mutation = trpc.useMutation("viewer.updateSAMLConfig", {
|
||||
onSuccess: (data: { provider: string | undefined }) => {
|
||||
showToast(t("saml_config_updated_successfully"), "success");
|
||||
setHasErrors(false); // dismiss any open errors
|
||||
setSAMLConfig(data?.provider ?? null);
|
||||
samlConfigRef.current.value = "";
|
||||
},
|
||||
onError: () => {
|
||||
setHasErrors(true);
|
||||
setErrorMessage(t("saml_configuration_update_failed"));
|
||||
document?.getElementsByTagName("main")[0]?.scrollTo({ top: 0, behavior: "smooth" });
|
||||
},
|
||||
});
|
||||
|
||||
const deleteMutation = trpc.useMutation("viewer.deleteSAMLConfig", {
|
||||
onSuccess: () => {
|
||||
showToast(t("saml_config_deleted_successfully"), "success");
|
||||
setHasErrors(false); // dismiss any open errors
|
||||
setSAMLConfig(null);
|
||||
samlConfigRef.current.value = "";
|
||||
},
|
||||
onError: () => {
|
||||
setHasErrors(true);
|
||||
setErrorMessage(t("saml_configuration_delete_failed"));
|
||||
document?.getElementsByTagName("main")[0]?.scrollTo({ top: 0, behavior: "smooth" });
|
||||
},
|
||||
});
|
||||
|
||||
const samlConfigRef = useRef<HTMLTextAreaElement>() as React.MutableRefObject<HTMLTextAreaElement>;
|
||||
|
||||
const [hasErrors, setHasErrors] = useState(false);
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
|
||||
async function updateSAMLConfigHandler(event: React.FormEvent<HTMLElement>) {
|
||||
event.preventDefault();
|
||||
|
||||
const rawMetadata = samlConfigRef.current.value;
|
||||
|
||||
// track Google logins. Without personal data/payload
|
||||
telemetry.event(telemetryEventTypes.samlConfig, collectPageParameters());
|
||||
|
||||
mutation.mutate({
|
||||
encodedRawMetadata: Buffer.from(rawMetadata).toString("base64"),
|
||||
teamId,
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteSAMLConfigHandler(event: React.MouseEvent<HTMLElement, MouseEvent>) {
|
||||
event.preventDefault();
|
||||
|
||||
deleteMutation.mutate({
|
||||
teamId,
|
||||
});
|
||||
}
|
||||
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<>
|
||||
{isSAMLLoginEnabled ? (
|
||||
<LicenseRequired>
|
||||
<hr className="mt-8" />
|
||||
<div className="mt-6">
|
||||
<h2 className="font-cal text-lg font-medium leading-6 text-gray-900">
|
||||
{t("saml_configuration")}
|
||||
<Badge className="ml-2 text-xs" variant={samlConfig ? "success" : "gray"}>
|
||||
{samlConfig ? t("enabled") : t("disabled")}
|
||||
</Badge>
|
||||
{samlConfig ? (
|
||||
<>
|
||||
<Badge className="ml-2 text-xs" variant="success">
|
||||
{samlConfig ? samlConfig : ""}
|
||||
</Badge>
|
||||
</>
|
||||
) : null}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{samlConfig ? (
|
||||
<div className="mt-2 flex">
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button
|
||||
color="warn"
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}>
|
||||
{t("delete_saml_configuration")}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<ConfirmationDialogContent
|
||||
variety="danger"
|
||||
title={t("delete_saml_configuration")}
|
||||
confirmBtnText={t("confirm_delete_saml_configuration")}
|
||||
cancelBtnText={t("cancel")}
|
||||
onConfirm={deleteSAMLConfigHandler}>
|
||||
{t("delete_saml_configuration_confirmation_message")}
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
) : (
|
||||
<p className="mt-1 text-sm text-gray-500">{!samlConfig ? t("saml_not_configured_yet") : ""}</p>
|
||||
)}
|
||||
|
||||
<p className="mt-1 text-sm text-gray-500">{t("saml_configuration_description")}</p>
|
||||
|
||||
<form className="mt-3 divide-y divide-gray-200 lg:col-span-9" onSubmit={updateSAMLConfigHandler}>
|
||||
{hasErrors && <Alert severity="error" title={errorMessage} />}
|
||||
|
||||
<TextArea
|
||||
data-testid="saml_config"
|
||||
ref={samlConfigRef}
|
||||
name="saml_config"
|
||||
id="saml_config"
|
||||
required={true}
|
||||
rows={10}
|
||||
placeholder={t("saml_configuration_placeholder")}
|
||||
/>
|
||||
|
||||
<div className="flex justify-end py-8">
|
||||
<Button type="submit">{t("save")}</Button>
|
||||
</div>
|
||||
<hr className="mt-4" />
|
||||
</form>
|
||||
</LicenseRequired>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import LicenseRequired from "@calcom/ee/common/components/v2/LicenseRequired";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@calcom/lib/telemetry";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { DialogFooter } from "@calcom/ui/Dialog";
|
||||
import { showToast } from "@calcom/ui/v2";
|
||||
import Button from "@calcom/ui/v2/core/Button";
|
||||
import { Form, TextArea } from "@calcom/ui/v2/core/form/fields";
|
||||
|
||||
interface TeamSSOValues {
|
||||
metadata: string;
|
||||
}
|
||||
|
||||
export default function ConfigDialogForm({
|
||||
teamId,
|
||||
handleClose,
|
||||
}: {
|
||||
teamId: number | null;
|
||||
handleClose: () => void;
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useContext();
|
||||
|
||||
const telemetry = useTelemetry();
|
||||
|
||||
const form = useForm<TeamSSOValues>();
|
||||
|
||||
const mutation = trpc.useMutation("viewer.saml.update", {
|
||||
async onSuccess() {
|
||||
telemetry.event(telemetryEventTypes.samlConfig, collectPageParameters());
|
||||
await utils.invalidateQueries(["viewer.saml.get"]);
|
||||
showToast(t("saml_config_updated_successfully"), "success");
|
||||
handleClose();
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<LicenseRequired>
|
||||
<Form
|
||||
form={form}
|
||||
handleSubmit={(values) => {
|
||||
mutation.mutate({
|
||||
teamId,
|
||||
encodedRawMetadata: Buffer.from(values.metadata).toString("base64"),
|
||||
});
|
||||
}}>
|
||||
<div className="mb-10 mt-1">
|
||||
<h2 className="font-semi-bold font-cal text-xl tracking-wide text-gray-900">
|
||||
{t("saml_configuration")}
|
||||
</h2>
|
||||
<p className="mt-1 mb-5 text-sm text-gray-500">{t("saml_configuration_description")}</p>
|
||||
</div>
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="metadata"
|
||||
render={({ field: { value } }) => (
|
||||
<div>
|
||||
<TextArea
|
||||
data-testid="saml_config"
|
||||
name="metadata"
|
||||
value={value}
|
||||
className="h-40"
|
||||
required={true}
|
||||
placeholder={t("saml_configuration_placeholder")}
|
||||
onChange={(e) => {
|
||||
form.setValue("metadata", e?.target.value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<DialogFooter>
|
||||
<Button type="button" color="secondary" onClick={handleClose} tabIndex={-1}>
|
||||
{t("cancel")}
|
||||
</Button>
|
||||
<Button type="submit" loading={form.formState.isSubmitting}>
|
||||
{t("save")}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</Form>
|
||||
</LicenseRequired>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/v2/LicenseRequired";
|
||||
import ConfigDialogForm from "@calcom/features/ee/sso/components/ConfigDialogForm";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Icon } from "@calcom/ui";
|
||||
import { Alert } from "@calcom/ui/Alert";
|
||||
import { ClipboardCopyIcon } from "@calcom/ui/Icon";
|
||||
import { Button, showToast, Label } from "@calcom/ui/v2";
|
||||
import Badge from "@calcom/ui/v2/core/Badge";
|
||||
import ConfirmationDialogContent from "@calcom/ui/v2/core/ConfirmationDialogContent";
|
||||
import { Dialog, DialogTrigger, DialogContent } from "@calcom/ui/v2/core/Dialog";
|
||||
import Meta from "@calcom/ui/v2/core/Meta";
|
||||
import SkeletonLoader from "@calcom/ui/v2/core/apps/SkeletonLoader";
|
||||
|
||||
export default function SAMLConfiguration({ teamId }: { teamId: number | null }) {
|
||||
const { t } = useLocale();
|
||||
const utils = trpc.useContext();
|
||||
|
||||
const [hasError, setHasError] = useState(false);
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
const [configModal, setConfigModal] = useState(false);
|
||||
|
||||
const { data: connection, isLoading } = trpc.useQuery(["viewer.saml.get", { teamId }], {
|
||||
onError: (err) => {
|
||||
setHasError(true);
|
||||
setErrorMessage(err.message);
|
||||
},
|
||||
onSuccess: () => {
|
||||
setHasError(false);
|
||||
setErrorMessage("");
|
||||
},
|
||||
});
|
||||
|
||||
const mutation = trpc.useMutation("viewer.saml.delete", {
|
||||
async onSuccess() {
|
||||
await utils.invalidateQueries(["viewer.saml.get"]);
|
||||
showToast(t("saml_config_deleted_successfully"), "success");
|
||||
},
|
||||
onError: (err) => {
|
||||
showToast(err.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
const deleteConnection = () => {
|
||||
mutation.mutate({
|
||||
teamId,
|
||||
});
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return <SkeletonLoader />;
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
return (
|
||||
<>
|
||||
<Meta title={t("saml_config")} description={t("saml_description")} />
|
||||
<Alert severity="warning" message={t(errorMessage)} className="mb-4 " />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Meta title={t("saml_config")} description={t("saml_description")} />
|
||||
<LicenseRequired>
|
||||
<div className="flex flex-col justify-between md:flex-row">
|
||||
<div className="mb-3">
|
||||
{connection && connection.provider ? (
|
||||
<Badge variant="green" bold>
|
||||
SAML SSO enabled via {connection.provider}
|
||||
</Badge>
|
||||
) : (
|
||||
<Badge variant="gray" bold>
|
||||
{t("saml_not_configured_yet")}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<Button
|
||||
color="secondary"
|
||||
StartIcon={Icon.FiDatabase}
|
||||
onClick={() => {
|
||||
setConfigModal(true);
|
||||
}}>
|
||||
{t("saml_btn_configure")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Service Provider Details */}
|
||||
{connection && connection.provider && (
|
||||
<>
|
||||
<hr className="border-1 my-8 border-gray-200" />
|
||||
<div className="mb-3 text-base font-semibold">{t("saml_sp_title")}</div>
|
||||
<p className="mt-3 text-sm font-normal leading-6 text-gray-700 dark:text-gray-300">
|
||||
{t("saml_sp_description")}
|
||||
</p>
|
||||
<div className="mt-5 flex flex-col">
|
||||
<div className="flex">
|
||||
<Label>{t("saml_sp_acs_url")}</Label>
|
||||
</div>
|
||||
<div className="flex">
|
||||
<code className="mr-1 w-full truncate rounded-sm bg-gray-100 py-2 px-3 font-mono text-gray-800">
|
||||
{connection.acsUrl}
|
||||
</code>
|
||||
<Button
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(connection.acsUrl);
|
||||
showToast(t("saml_sp_acs_url_copied"), "success");
|
||||
}}
|
||||
type="button"
|
||||
className="px-4 text-base">
|
||||
<ClipboardCopyIcon className="h-5 w-5 text-neutral-100" />
|
||||
{t("copy")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-5 flex flex-col">
|
||||
<div className="flex">
|
||||
<Label>{t("saml_sp_entity_id")}</Label>
|
||||
</div>
|
||||
<div className="flex">
|
||||
<code className="mr-1 w-full truncate rounded-sm bg-gray-100 py-2 px-3 font-mono text-gray-800">
|
||||
{connection.entityId}
|
||||
</code>
|
||||
<Button
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(connection.entityId);
|
||||
showToast(t("saml_sp_entity_id_copied"), "success");
|
||||
}}
|
||||
type="button"
|
||||
className="px-4 text-base">
|
||||
<ClipboardCopyIcon className="h-5 w-5 text-neutral-100" />
|
||||
{t("copy")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Danger Zone and Delete Confirmation */}
|
||||
{connection && connection.provider && (
|
||||
<>
|
||||
<hr className="border-1 my-8 border-gray-200" />
|
||||
<div className="mb-3 text-base font-semibold">{t("danger_zone")}</div>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button color="destructive" className="border" StartIcon={Icon.FiTrash2}>
|
||||
{t("delete_saml_configuration")}
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<ConfirmationDialogContent
|
||||
variety="danger"
|
||||
title={t("delete_saml_configuration")}
|
||||
confirmBtnText={t("confirm_delete_saml_configuration")}
|
||||
onConfirm={deleteConnection}>
|
||||
{t("delete_saml_configuration_confirmation_message")}
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Add/Update SAML Connection */}
|
||||
<Dialog open={configModal} onOpenChange={setConfigModal}>
|
||||
<DialogContent type="creation" useOwnActionButtons>
|
||||
<ConfigDialogForm handleClose={() => setConfigModal(false)} teamId={teamId} />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</LicenseRequired>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import jackson, {
|
||||
IConnectionAPIController,
|
||||
IOAuthController,
|
||||
JacksonOption,
|
||||
ISPSAMLConfig,
|
||||
} from "@boxyhq/saml-jackson";
|
||||
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
import { samlDatabaseUrl, samlAudience, samlPath } from "./saml";
|
||||
|
||||
// Set the required options. Refer to https://github.com/boxyhq/jackson#configuration for the full list
|
||||
const opts: JacksonOption = {
|
||||
externalUrl: WEBAPP_URL,
|
||||
samlPath,
|
||||
samlAudience,
|
||||
db: {
|
||||
engine: "sql",
|
||||
type: "postgres",
|
||||
url: samlDatabaseUrl,
|
||||
encryptionKey: process.env.CALENDSO_ENCRYPTION_KEY,
|
||||
},
|
||||
};
|
||||
|
||||
let connectionController: IConnectionAPIController;
|
||||
let oauthController: IOAuthController;
|
||||
let samlSPConfig: ISPSAMLConfig;
|
||||
|
||||
const g = global as any;
|
||||
|
||||
export default async function init() {
|
||||
if (!g.connectionController || !g.oauthController) {
|
||||
const ret = await jackson(opts);
|
||||
|
||||
connectionController = ret.connectionAPIController;
|
||||
oauthController = ret.oauthController;
|
||||
samlSPConfig = ret.spConfig;
|
||||
|
||||
g.connectionController = connectionController;
|
||||
g.oauthController = oauthController;
|
||||
g.samlSPConfig = samlSPConfig;
|
||||
} else {
|
||||
connectionController = g.connectionController;
|
||||
oauthController = g.oauthController;
|
||||
samlSPConfig = g.samlSPConfig;
|
||||
}
|
||||
|
||||
return {
|
||||
connectionController,
|
||||
oauthController,
|
||||
samlSPConfig,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { PrismaClient, UserPlan } from "@prisma/client";
|
||||
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
import { isTeamAdmin } from "@calcom/lib/server/queries/teams";
|
||||
import { TRPCError } from "@calcom/trpc/server";
|
||||
|
||||
export const samlDatabaseUrl = process.env.SAML_DATABASE_URL || "";
|
||||
export const isSAMLLoginEnabled = samlDatabaseUrl.length > 0;
|
||||
|
||||
export const samlTenantID = "Cal.com";
|
||||
export const samlProductID = "Cal.com";
|
||||
export const samlAudience = "https://saml.cal.com";
|
||||
export const samlPath = "/api/auth/saml/callback";
|
||||
|
||||
export const hostedCal = Boolean(HOSTED_CAL_FEATURES);
|
||||
export const tenantPrefix = "team-";
|
||||
|
||||
const samlAdmins = (process.env.SAML_ADMINS || "").split(",");
|
||||
|
||||
export const isSAMLAdmin = (email: string) => {
|
||||
for (const admin of samlAdmins) {
|
||||
if (admin.toLowerCase() === email.toLowerCase() && admin.toUpperCase() === email.toUpperCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export const samlTenantProduct = async (prisma: PrismaClient, email: string) => {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
email,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
invitedTo: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Unauthorized Request",
|
||||
});
|
||||
}
|
||||
|
||||
if (!user.invitedTo) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
message:
|
||||
"Could not find a SAML Identity Provider for your email. Please contact your admin to ensure you have been given access to Cal",
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
tenant: tenantPrefix + user.invitedTo,
|
||||
product: samlProductID,
|
||||
};
|
||||
};
|
||||
|
||||
export const canAccess = async (
|
||||
user: { id: number; plan: UserPlan; email: string },
|
||||
teamId: number | null
|
||||
) => {
|
||||
const { id: userId, plan, email } = user;
|
||||
|
||||
if (!isSAMLLoginEnabled) {
|
||||
return {
|
||||
message: "To enable this feature, add value for `SAML_DATABASE_URL` and `SAML_ADMINS` to your `.env`",
|
||||
access: false,
|
||||
};
|
||||
}
|
||||
|
||||
// Hosted
|
||||
if (HOSTED_CAL_FEATURES) {
|
||||
if (teamId === null || !(await isTeamAdmin(userId, teamId))) {
|
||||
return {
|
||||
message: "dont_have_permission",
|
||||
access: false,
|
||||
};
|
||||
}
|
||||
|
||||
if (plan != UserPlan.PRO) {
|
||||
return {
|
||||
message: "app_upgrade_description",
|
||||
access: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Self-hosted
|
||||
if (!HOSTED_CAL_FEATURES) {
|
||||
if (!isSAMLAdmin(email)) {
|
||||
return {
|
||||
message: "dont_have_permission",
|
||||
access: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
message: "success",
|
||||
access: true,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import SkeletonLoader from "@calcom/ui/v2/core/apps/SkeletonLoader";
|
||||
import { getLayout } from "@calcom/ui/v2/core/layouts/SettingsLayout";
|
||||
|
||||
import SAMLConfiguration from "../components/SAMLConfiguration";
|
||||
|
||||
const SAMLSSO = () => {
|
||||
const router = useRouter();
|
||||
|
||||
if (!HOSTED_CAL_FEATURES) {
|
||||
router.push("/404");
|
||||
}
|
||||
|
||||
const teamId = Number(router.query.id);
|
||||
|
||||
const { data: team, isLoading } = trpc.useQuery(["viewer.teams.get", { teamId }], {
|
||||
onError: () => {
|
||||
router.push("/settings");
|
||||
},
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
return <SkeletonLoader />;
|
||||
}
|
||||
|
||||
if (!team) {
|
||||
router.push("/404");
|
||||
return;
|
||||
}
|
||||
|
||||
return <SAMLConfiguration teamId={teamId} />;
|
||||
};
|
||||
|
||||
SAMLSSO.getLayout = getLayout;
|
||||
|
||||
export default SAMLSSO;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
import { getLayout } from "@calcom/ui/v2/core/layouts/SettingsLayout";
|
||||
|
||||
import SAMLConfiguration from "../components/SAMLConfiguration";
|
||||
|
||||
const SAMLSSO = () => {
|
||||
const router = useRouter();
|
||||
|
||||
if (HOSTED_CAL_FEATURES) {
|
||||
router.push("/404");
|
||||
}
|
||||
|
||||
const teamId = null;
|
||||
|
||||
return <SAMLConfiguration teamId={teamId} />;
|
||||
};
|
||||
|
||||
SAMLSSO.getLayout = getLayout;
|
||||
|
||||
export default SAMLSSO;
|
||||
Reference in new issue
Block a user