Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

refactor(web): Migrate sso settings table to design system (#17863)

Ben Bachem01819352ff7b
diff --git a/web/src/components/design-system/table/Table.tsx b/web/src/components/design-system/table/Table.tsx
index 8c16269eb2..5ed97e0546 100644
--- a/web/src/components/design-system/table/Table.tsx
+++ b/web/src/components/design-system/table/Table.tsx
@@ -76,24 +76,29 @@ export function Table<TData extends object>({
enableResizing: false,
headerClassName: "text-right",
cellClassName: "text-right",
- cell: ({ row }) => (
- <div
- className="ml-auto flex size-6 items-center justify-end"
- onClick={(event) => event.stopPropagation()}
- >
- <DropdownMenu items={actions(row.original)} placement="bottom-end">
- {({ getTriggerProps }) => (
- <IconButton
- icon={MoreVertical}
- label="Open actions menu"
- size="sm"
- variant="subtle"
- {...getTriggerProps()}
- />
- )}
- </DropdownMenu>
- </div>
- ),
+ cell: ({ row }) => {
+ const items = actions(row.original);
+
+ return (
+ <div
+ className="ml-auto flex size-6 items-center justify-end"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <DropdownMenu items={items} placement="bottom-end">
+ {({ getTriggerProps }) => (
+ <IconButton
+ icon={MoreVertical}
+ label="Open actions menu"
+ size="sm"
+ variant="subtle"
+ {...getTriggerProps()}
+ disabled={items.length === 0}
+ />
+ )}
+ </DropdownMenu>
+ </div>
+ );
+ },
loadingCell: (
<div className="ml-auto flex h-4 w-6 items-center justify-center">
<MoreVertical
diff --git a/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx b/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx
new file mode 100644
index 0000000000..76dc6327d1
--- /dev/null
+++ b/web/src/ee/features/sso-settings/components/DeleteSsoConfigDialogController.tsx
@@ -0,0 +1,53 @@
+import { useState } from "react";
+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";
+import { showErrorToast, showSuccessToast } from "@/src/features/notifications";
+import { api } from "@/src/utils/api";
+
+export function DeleteSsoConfigDialogController({
+ orgId,
+ children,
+}: {
+ orgId: string;
+ children: (control: {
+ openDialog: (domain: string) => void;
+ }) => React.ReactNode;
+}) {
+ const [selectedDomain, setSelectedDomain] = useState<string | null>(null);
+ const utils = api.useUtils();
+
+ const deleteMutation = api.ssoConfig.delete.useMutation({
+ onSuccess: () => {
+ utils.ssoConfig.get.invalidate({ orgId });
+ showSuccessToast({
+ title: "SSO disabled",
+ description: `SSO for @${selectedDomain} has been removed.`,
+ });
+ },
+ onError: (err) => {
+ showErrorToast("Failed to remove SSO", err.message);
+ },
+ });
+
+ return (
+ <ConfirmationDialogController
+ title={`Remove SSO for @${selectedDomain ?? "this domain"}?`}
+ text="Users at this domain will be able to sign in with any enabled method again. Active sessions are not invalidated."
+ confirmLabel="Remove"
+ variant="destructive"
+ loading={deleteMutation.isPending}
+ onConfirm={async () => {
+ if (!selectedDomain) return;
+ await deleteMutation.mutateAsync({ orgId, domain: selectedDomain });
+ }}
+ >
+ {({ openDialog }) =>
+ children({
+ openDialog: (domain) => {
+ setSelectedDomain(domain);
+ openDialog();
+ },
+ })
+ }
+ </ConfirmationDialogController>
+ );
+}
diff --git a/web/src/ee/features/sso-settings/components/SSOSettings.tsx b/web/src/ee/features/sso-settings/components/SSOSettings.tsx
index 77894bdb8c..22ae7897b6 100644
--- a/web/src/ee/features/sso-settings/components/SSOSettings.tsx
+++ b/web/src/ee/features/sso-settings/components/SSOSettings.tsx
@@ -1,111 +1,10 @@
-import { showErrorToast, showSuccessToast } from "@/src/features/notifications";
import { Alert } from "@/src/components/design-system/Alert/Alert";
-import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";
-import { DialogController } from "@/src/components/design-system/DialogController/DialogController";
-import { Badge } from "@/src/components/ui/badge";
-import { Button } from "@/src/components/ui/button";
-import { Card } from "@/src/components/ui/card";
-import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";
-import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
-import { SimpleDataTable } from "@/src/components/table/simple-data-table";
-import { type LangfuseColumnDef } from "@/src/components/table/types";
-import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";
-import {
- DialogBody,
- DialogContent,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from "@/src/components/ui/dialog";
-import {
- Form,
- FormControl,
- FormDescription,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from "@/src/components/ui/form";
-import { Input } from "@/src/components/ui/input";
import Header from "@/src/components/layouts/header";
import { useHasEntitlement } from "@/src/features/entitlements";
import { useHasOrganizationAccess } from "@/src/features/rbac";
import { VerifiedDomainsSettings } from "@/src/ee/features/verified-domains";
-import { SsoProviderSchema } from "@/src/ee/features/multi-tenant-sso";
-import { api } from "@/src/utils/api";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { AlertCircle, Check, Copy, TrashIcon } from "lucide-react";
-import { useMemo, useState } from "react";
-import { useForm } from "react-hook-form";
-import { z } from "zod";
-import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
-
-const SSO_PROVIDERS: ReadonlyArray<{
- id: SsoProviderSchema["authProvider"];
- label: string;
- fields: ReadonlyArray<"issuer" | "tenantId" | "baseUrl" | "name">;
-}> = [
- { id: "google", label: "Google", fields: [] },
- { id: "github", label: "GitHub", fields: [] },
- { id: "github-enterprise", label: "GitHub Enterprise", fields: ["baseUrl"] },
- { id: "gitlab", label: "GitLab", fields: [] },
- { id: "auth0", label: "Auth0", fields: ["issuer"] },
- { id: "okta", label: "Okta", fields: ["issuer"] },
- { id: "authentik", label: "Authentik", fields: ["issuer"] },
- { id: "onelogin", label: "OneLogin", fields: ["issuer"] },
- { id: "azure-ad", label: "Azure AD / Entra ID", fields: ["tenantId"] },
- { id: "cognito", label: "AWS Cognito", fields: ["issuer"] },
- { id: "keycloak", label: "Keycloak", fields: ["issuer"] },
- { id: "jumpcloud", label: "JumpCloud", fields: ["issuer"] },
- // Custom OIDC requires a display name on the schema; surface it in the form.
- { id: "custom", label: "Custom OIDC", fields: ["name", "issuer"] },
-];
-
-const providerLabel = (id: string) =>
- SSO_PROVIDERS.find((p) => p.id === id)?.label ?? id;
-
-// Loose form schema; the strict validation lives in SsoProviderSchema and runs
-// at submit time. Keeping the form schema permissive lets users mid-edit a
-// field without immediate noise from required-field errors on every render.
-const formSchema = z.object({
- authProvider: z.enum(SSO_PROVIDERS.map((p) => p.id) as [string, ...string[]]),
- authConfig: z.object({
- clientId: z.string().min(1, "Required"),
- clientSecret: z.string().min(1, "Required"),
- issuer: z.string().optional(),
- tenantId: z.string().optional(),
- baseUrl: z.string().optional(),
- // Required by CustomProviderSchema; optional in the form so other
- // providers don't carry a stray field. The strict provider schema
- // enforces presence at submit for `custom`.
- name: z.string().optional(),
- idToken: z.boolean().optional(),
- }),
-});
-
-type FormValues = z.infer<typeof formSchema>;
-
-type AuthConfigFormField = `authConfig.${
- | "clientId"
- | "clientSecret"
- | "issuer"
- | "tenantId"
- | "baseUrl"
- | "name"
- | "idToken"}`;
-
-type SsoConfigRow = {
- domain: string;
- authProvider: string;
- authConfig: Record<string, unknown> | null;
- createdAt: Date;
- updatedAt: Date;
-};
-
-type SsoConfigTableRow = {
- domain: string;
- config: SsoConfigRow | null;
-};
+import { AlertCircle } from "lucide-react";
+import { ConnectedSsoConfigsTable } from "./SsoConfigsTable/ConnectedSsoConfigsTable";
export const SSOSettings = ({ orgId }: { orgId: string }) => {
const hasEntitlement = useHasEntitlement("cloud-multi-tenant-sso");
@@ -164,635 +63,8 @@ export const SSOSettings = ({ orgId }: { orgId: string }) => {
<VerifiedDomainsSettings orgId={orgId} />
<div className="space-y-6">
{heading}
- <SsoConfigsTable orgId={orgId} />
+ <ConnectedSsoConfigsTable orgId={orgId} />
</div>
</div>
);
};
-
-function SsoConfigsTable({ orgId }: { orgId: string }) {
- const verifiedDomainsQuery = api.verifiedDomain.list.useQuery({ orgId });
- const ssoConfigsQuery = api.ssoConfig.get.useQuery({ orgId });
-
- const verifiedDomains = useMemo(
- () =>
- verifiedDomainsQuery.data?.filter(
- (domain: { verifiedAt: Date | null }) => domain.verifiedAt != null,
- ) ?? [],
- [verifiedDomainsQuery.data],
- );
- const configByDomain = useMemo(() => {
- const map = new Map<string, SsoConfigRow>();
- ssoConfigsQuery.data?.forEach((config: SsoConfigRow) =>
- map.set(config.domain, config),
- );
- return map;
- }, [ssoConfigsQuery.data]);
-
- const data: SsoConfigTableRow[] = verifiedDomains.map(
- (domain: { domain: string }) => ({
- domain: domain.domain,
- config: configByDomain.get(domain.domain) ?? null,
- }),
- );
-
- if (verifiedDomains.length === 0) {
- return (
- <Card className="overflow-hidden">
- <p className="text-muted-foreground px-6 py-12 text-center text-sm">
- Verify a domain in the section above to configure SSO for it.
- </p>
- </Card>
- );
- }
-
- return (
- <SsoConfigDialogController orgId={orgId}>
- {({ openDialog: openConfigDialog }) => (
- <DeleteSsoConfigDialogController orgId={orgId}>
- {({ openDialog: openDeleteDialog }) => {
- const columns: LangfuseColumnDef<SsoConfigTableRow>[] = [
- createTextTableColumn<SsoConfigTableRow>({
- accessorKey: "domain",
- header: "Domain",
- }),
- {
- accessorKey: "config",
- header: "Provider",
- cell: ({ row }) =>
- row.original.config ? (
- <Badge variant="default">
- {providerLabel(row.original.config.authProvider)}
- </Badge>
- ) : (
- <Badge variant="secondary">Not configured</Badge>
- ),
- },
- {
- accessorKey: "config",
- id: "updatedAt",
- header: "Updated",
- hideBelowMd: true,
- cell: ({ row }) =>
- row.original.config
- ? row.original.config.updatedAt.toLocaleDateString()
- : "—",
- },
- {
- accessorKey: "domain",
- id: "actions",
- header: "",
- cell: ({ row }) => (
- <div className="flex items-center justify-end gap-2">
- <Button
- size="sm"
- variant={row.original.config ? "outline" : "default"}
- onClick={() => openConfigDialog(row.original)}
- >
- {row.original.config ? "Update" : "Configure SSO"}
- </Button>
- {row.original.config ? (
- <Button
- variant="ghost"
- size="icon-xs"
- aria-label={`Delete SSO for ${row.original.domain}`}
- onClick={() => openDeleteDialog(row.original.domain)}
- >
- <TrashIcon className="h-4 w-4" />
- </Button>
- ) : null}
- </div>
- ),
- },
- ];
-
- return (
- <Card className="mb-4 overflow-hidden">
- <SimpleDataTable
- columns={columns}
- data={data}
- isLoading={false}
- noResults={null}
- bodyTone="muted"
- rowVariant="primary-hover"
- />
- </Card>
- );
- }}
- </DeleteSsoConfigDialogController>
- )}
- </SsoConfigDialogController>
- );
-}
-
-function SsoConfigDialogController({
- orgId,
- children,
-}: {
- orgId: string;
- children: (control: {
- openDialog: (config: SsoConfigTableRow) => void;
- }) => React.ReactNode;
-}) {
- return (
- <DialogController<SsoConfigTableRow>
- renderDialog={({ state, closeDialog }) => (
- <DialogContent className="sm:max-w-xl">
- <SsoConfigDialogContent
- key={state.domain}
- orgId={orgId}
- domain={state.domain}
- existing={state.config}
- closeDialog={closeDialog}
- />
- </DialogContent>
- )}
- >
- {({ openDialog }) => children({ openDialog })}
- </DialogController>
- );
-}
-
-function SsoConfigDialogContent({
- orgId,
- domain,
- existing,
- closeDialog,
-}: {
- orgId: string;
- domain: string;
- existing: SsoConfigRow | null;
- closeDialog: () => void;
-}) {
- const [pendingValues, setPendingValues] = useState<FormValues | null>(null);
- const utils = api.useUtils();
-
- const defaultValues = useMemo<FormValues>(() => {
- const cfg = (existing?.authConfig ?? {}) as Record<string, unknown>;
- const enterprise = cfg.enterprise as { baseUrl?: string } | undefined;
- return {
- authProvider:
- existing?.authProvider ?? ("okta" as SsoProviderSchema["authProvider"]),
- authConfig: {
- clientId: typeof cfg.clientId === "string" ? cfg.clientId : "",
- clientSecret: "",
- issuer: typeof cfg.issuer === "string" ? cfg.issuer : "",
- tenantId: typeof cfg.tenantId === "string" ? cfg.tenantId : "",
- baseUrl: enterprise?.baseUrl ?? "",
- name: typeof cfg.name === "string" ? cfg.name : "",
- idToken: typeof cfg.idToken === "boolean" ? cfg.idToken : true,
- },
- };
- }, [existing]);
-
- const form = useForm<FormValues>({
- resolver: zodResolver(formSchema),
- defaultValues,
- });
- const selectedProvider = form.watch("authProvider");
- const providerSpec = useMemo(
- () =>
- SSO_PROVIDERS.find((p) => p.id === selectedProvider) ?? SSO_PROVIDERS[0],
- [selectedProvider],
- );
-
- const callbackUrl = useMemo(() => {
- if (typeof window === "undefined") return "";
- return `${window.location.origin}/api/auth/callback/${domain}.${selectedProvider}`;
- }, [domain, selectedProvider]);
-
- const saveMutation = api.ssoConfig.save.useMutation({
- onSuccess: () => {
- utils.ssoConfig.get.invalidate({ orgId });
- showSuccessToast({
- title: existing ? "SSO updated" : "SSO configured",
- description: `Active for @${domain} within 1 hour.`,
- });
- closeDialog();
- setPendingValues(null);
- form.reset();
- },
- onError: (err) => {
- showErrorToast(
- existing ? "Update failed" : "SSO configuration failed",
- err.message,
- );
- },
- });
-
- async function handleConfirm() {
- if (!pendingValues) return;
- const payload = buildSsoPayload(domain, pendingValues);
- const parsed = SsoProviderSchema.safeParse(payload);
- if (!parsed.success) {
- const firstIssue = parsed.error.issues[0];
- const schemaPath = firstIssue.path.join(".");
- // `buildSsoPayload` re-nests `baseUrl` under `enterprise` for
- // github-enterprise; the strict schema reports errors at the nested
- // path, but the form field is registered flat. Map back so
- // `setError` lands on a watched field and the inline message renders.
- const formPath =
- schemaPath === "authConfig.enterprise.baseUrl"
- ? "authConfig.baseUrl"
- : schemaPath;
- const formField = formPath.startsWith("authConfig.")
- ? (formPath as AuthConfigFormField)
- : "authProvider";
- form.setError(formField, { message: firstIssue.message });
- // Defensive fallback: if a future schema path doesn't map cleanly to
- // a registered form field, surface a toast so the user is never left
- // with a silently-closing dialog and no feedback.
- const FORM_FIELDS = [
- "authProvider",
- "authConfig.clientId",
- "authConfig.clientSecret",
- "authConfig.issuer",
- "authConfig.tenantId",
- "authConfig.baseUrl",
- "authConfig.name",
- "authConfig.idToken",
- ];
- if (!FORM_FIELDS.includes(formField)) {
- showErrorToast(
- existing ? "Update failed" : "SSO configuration failed",
- firstIssue.message,
- );
- }
- return;
- }
- await saveMutation.mutateAsync({ orgId, payload: parsed.data });
- }
-
- return (
- <ConfirmationDialogController
- title={
- existing
- ? `Replace SSO for @${domain}?`
- : `Activate SSO for @${domain}?`
- }
- text={`Saving will activate SSO for @${domain} within 1 hour. Every user at that domain will be redirected to your identity provider on sign-in - they will not be able to use Google, GitHub, password, or any other method until SSO is deleted.${existing ? " The new credentials will replace the active configuration." : ""} Tip: sign in via the new SSO in a second browser to confirm it works before closing this tab.`}
- confirmLabel={existing ? "Replace" : "Activate SSO"}
- variant="default"
- loading={saveMutation.isPending}
- onConfirm={handleConfirm}
- >
- {({ openDialog }) => (
- <>
- <DialogHeader>
- <DialogTitle>
- {existing
- ? `Update SSO for ${domain}`
- : `Configure SSO for ${domain}`}
- </DialogTitle>
- </DialogHeader>
- <Form {...form}>
- <form
- onSubmit={form.handleSubmit((values) => {
- setPendingValues(values);
- openDialog();
- })}
- >
- <DialogBody className="space-y-4">
- <FormField
- control={form.control}
- name="authProvider"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Provider</FormLabel>
- <FormControl>
- <SelectInput
- value={field.value}
- onValueChange={field.onChange}
- placeholder="Select an SSO provider"
- options={SSO_PROVIDERS.map((provider) => ({
- value: provider.id,
- label: provider.label,
- }))}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <CallbackUrlPanel callbackUrl={callbackUrl} />
-
- {providerSpec.fields.includes("name") ? (
- <FormField
- control={form.control}
- name="authConfig.name"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Display Name</FormLabel>
- <FormControl>
- <Input placeholder="Acme SSO" {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- ) : null}
-
- <FormField
- control={form.control}
- name="authConfig.clientId"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Client ID</FormLabel>
- <FormControl>
- <Input {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="authConfig.clientSecret"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Client Secret</FormLabel>
- <FormControl>
- <Input
- type="password"
- autoComplete="off"
- placeholder={
- existing ? "Re-enter to update" : undefined
- }
- {...field}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
-
- {providerSpec.fields.includes("issuer") ? (
- <FormField
- control={form.control}
- name="authConfig.issuer"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Issuer URL</FormLabel>
- <FormControl>
- <Input
- placeholder="https://example.okta.com"
- {...field}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- ) : null}
-
- {providerSpec.fields.includes("tenantId") ? (
- <FormField
- control={form.control}
- name="authConfig.tenantId"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Tenant ID</FormLabel>
- <FormControl>
- <Input {...field} />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- ) : null}
-
- {providerSpec.fields.includes("baseUrl") ? (
- <FormField
- control={form.control}
- name="authConfig.baseUrl"
- render={({ field }) => (
- <FormItem>
- <FormLabel>Base URL</FormLabel>
- <FormControl>
- <Input
- placeholder="https://github.acme.com"
- {...field}
- />
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- ) : null}
-
- {selectedProvider === "custom" ? (
- <>
- <FormField
- control={form.control}
- name="authConfig.idToken"
- render={({ field }) => (
- <FormItem className="flex flex-row items-start space-y-0 space-x-3 rounded-md border p-4">
- <FormControl>
- <Checkbox
- checked={field.value ?? false}
- onCheckedChange={(checked) =>
- field.onChange(checked === true)
- }
- />
- </FormControl>
- <div className="space-y-1 leading-none">
- <FormLabel>
- Use id_token claims only (skip userinfo)
- </FormLabel>
- <FormDescription>
- Leave off for IdPs that release email only via the
- userinfo endpoint.
- </FormDescription>
- </div>
- </FormItem>
- )}
- />
- </>
- ) : null}
- </DialogBody>
- <DialogFooter>
- <Button type="button" variant="ghost" onClick={closeDialog}>
- Cancel
- </Button>
- <Button type="submit" loading={saveMutation.isPending}>
- Save
- </Button>
- </DialogFooter>
- </form>
- </Form>
- </>
- )}
- </ConfirmationDialogController>
- );
-}
-
-function CallbackUrlPanel({ callbackUrl }: { callbackUrl: string }) {
- const columns: LangfuseColumnDef<{ url: string }>[] = [
- {
- accessorKey: "url",
- header: "URL",
- cell: ({ getValue }) => (
- <CopyableCallbackUrl value={getValue<string>()} />
- ),
- },
- ];
-
- return (
- <div>
- <p className="mb-2 text-sm font-bold">Callback URL</p>
- <Card className="overflow-hidden">
- <SimpleDataTable
- columns={columns}
- data={[{ url: callbackUrl }]}
- isLoading={false}
- noResults={null}
- />
- </Card>
- <p className="text-muted-foreground mt-2 text-xs">
- Add this URL as an authorized redirect URI in your identity provider.
- </p>
- </div>
- );
-}
-
-function CopyableCallbackUrl({ value }: { value: string }) {
- const { copy, isCopied } = useCopyToClipboard();
-
- return (
- <div className="relative pr-8 font-mono break-all">
- <span>{value}</span>
- <Button
- variant="ghost"
- size="icon-xs"
- className="absolute top-1/2 right-0 -translate-y-1/2"
- title="Copy to clipboard"
- aria-label="Copy to clipboard"
- onClick={async (event) => {
- event.preventDefault();
- const button = event.currentTarget;
- await copy(value).catch(() => undefined);
- button.focus();
- }}
- >
- {isCopied ? (
- <Check className="h-3 w-3" />
- ) : (
- <Copy className="h-3 w-3" />
- )}
- </Button>
- </div>
- );
-}
-
-function DeleteSsoConfigDialogController({
- orgId,
- children,
-}: {
- orgId: string;
- children: (control: {
- openDialog: (domain: string) => void;
- }) => React.ReactNode;
-}) {
- const [selectedDomain, setSelectedDomain] = useState<string | null>(null);
- const utils = api.useUtils();
-
- const deleteMutation = api.ssoConfig.delete.useMutation({
- onSuccess: () => {
- utils.ssoConfig.get.invalidate({ orgId });
- showSuccessToast({
- title: "SSO disabled",
- description: `SSO for @${selectedDomain} has been removed.`,
- });
- },
- onError: (err) => {
- showErrorToast("Failed to remove SSO", err.message);
- },
- });
-
- return (
- <ConfirmationDialogController
- title={`Remove SSO for @${selectedDomain ?? "this domain"}?`}
- text="Users at this domain will be able to sign in with any enabled method again. Active sessions are not invalidated."
- confirmLabel="Remove"
- variant="destructive"
- loading={deleteMutation.isPending}
- onConfirm={async () => {
- if (!selectedDomain) return;
- await deleteMutation.mutateAsync({ orgId, domain: selectedDomain });
- }}
- >
- {({ openDialog }) =>
- children({
- openDialog: (domain) => {
- setSelectedDomain(domain);
- openDialog();
- },
- })
- }
- </ConfirmationDialogController>
- );
-}
-
-// Build the SsoProviderSchema-shaped payload from the flat form values.
-// Handles the nested github-enterprise.enterprise.baseUrl shape.
-function buildSsoPayload(domain: string, values: FormValues) {
- const { authProvider, authConfig } = values;
- // allowDangerousEmailAccountLinking is required for SSO migration of
- // existing accounts. Cross-tenant misuse is prevented by the DNS-verified
- // domain check at save time + the runtime domain enforcement in
- // web/src/server/auth.ts.
- const base = {
- clientId: authConfig.clientId,
- clientSecret: authConfig.clientSecret,
- allowDangerousEmailAccountLinking: true,
- };
-
- switch (authProvider) {
- case "google":
- case "github":
- case "gitlab":
- return { domain, authProvider, authConfig: base };
- case "github-enterprise":
- return {
- domain,
- authProvider,
- authConfig: {
- ...base,
- enterprise: { baseUrl: authConfig.baseUrl ?? "" },
- },
- };
- case "azure-ad":
- return {
- domain,
- authProvider,
- authConfig: { ...base, tenantId: authConfig.tenantId ?? "" },
- };
- case "auth0":
- case "okta":
- case "authentik":
- case "onelogin":
- case "cognito":
- case "keycloak":
- case "jumpcloud":
- return {
- domain,
- authProvider,
- authConfig: { ...base, issuer: authConfig.issuer ?? "" },
- };
- case "custom":
- return {
- domain,
- authProvider,
- authConfig: {
- ...base,
- issuer: authConfig.issuer ?? "",
- name: authConfig.name ?? "",
- idToken: authConfig.idToken ?? true,
- },
- };
- default:
- return { domain, authProvider, authConfig: base };
- }
-}
diff --git a/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx b/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx
new file mode 100644
index 0000000000..37170f8257
--- /dev/null
+++ b/web/src/ee/features/sso-settings/components/SsoConfigDialogController.tsx
@@ -0,0 +1,552 @@
+import { showErrorToast, showSuccessToast } from "@/src/features/notifications";
+import { ConfirmationDialogController } from "@/src/components/design-system/ConfirmationDialogController/ConfirmationDialogController";
+import { DialogController } from "@/src/components/design-system/DialogController/DialogController";
+import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";
+import { Button } from "@/src/components/ui/button";
+import { Card } from "@/src/components/ui/card";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";
+import {
+ DialogBody,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/src/components/ui/dialog";
+import {
+ Form,
+ FormControl,
+ FormDescription,
+ FormField,
+ FormItem,
+ FormLabel,
+ FormMessage,
+} from "@/src/components/ui/form";
+import { Input } from "@/src/components/ui/input";
+import { SsoProviderSchema } from "@/src/ee/features/multi-tenant-sso";
+import { api } from "@/src/utils/api";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Check, Copy } from "lucide-react";
+import { useMemo, useState } from "react";
+import { useForm } from "react-hook-form";
+import { z } from "zod";
+import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
+import {
+ type SsoConfigRow,
+ type SsoConfigTableRow,
+} from "./SsoConfigsTable/SsoConfigsTable";
+
+const SSO_PROVIDERS: ReadonlyArray<{
+ id: SsoProviderSchema["authProvider"];
+ label: string;
+ fields: ReadonlyArray<"issuer" | "tenantId" | "baseUrl" | "name">;
+}> = [
+ { id: "google", label: "Google", fields: [] },
+ { id: "github", label: "GitHub", fields: [] },
+ { id: "github-enterprise", label: "GitHub Enterprise", fields: ["baseUrl"] },
+ { id: "gitlab", label: "GitLab", fields: [] },
+ { id: "auth0", label: "Auth0", fields: ["issuer"] },
+ { id: "okta", label: "Okta", fields: ["issuer"] },
+ { id: "authentik", label: "Authentik", fields: ["issuer"] },
+ { id: "onelogin", label: "OneLogin", fields: ["issuer"] },
+ { id: "azure-ad", label: "Azure AD / Entra ID", fields: ["tenantId"] },
+ { id: "cognito", label: "AWS Cognito", fields: ["issuer"] },
+ { id: "keycloak", label: "Keycloak", fields: ["issuer"] },
+ { id: "jumpcloud", label: "JumpCloud", fields: ["issuer"] },
+ // Custom OIDC requires a display name on the schema; surface it in the form.
+ { id: "custom", label: "Custom OIDC", fields: ["name", "issuer"] },
+];
+
+// Loose form schema; the strict validation lives in SsoProviderSchema and runs
+// at submit time. Keeping the form schema permissive lets users mid-edit a
+// field without immediate noise from required-field errors on every render.
+const formSchema = z.object({
+ authProvider: z.enum(SSO_PROVIDERS.map((p) => p.id) as [string, ...string[]]),
+ authConfig: z.object({
+ clientId: z.string().min(1, "Required"),
+ clientSecret: z.string().min(1, "Required"),
+ issuer: z.string().optional(),
+ tenantId: z.string().optional(),
+ baseUrl: z.string().optional(),
+ // Required by CustomProviderSchema; optional in the form so other
+ // providers don't carry a stray field. The strict provider schema
+ // enforces presence at submit for `custom`.
+ name: z.string().optional(),
+ idToken: z.boolean().optional(),
+ }),
+});
+
+type FormValues = z.infer<typeof formSchema>;
+
+type AuthConfigFormField = `authConfig.${
+ | "clientId"
+ | "clientSecret"
+ | "issuer"
+ | "tenantId"
+ | "baseUrl"
+ | "name"
+ | "idToken"}`;
+
+export function SsoConfigDialogController({
+ orgId,
+ children,
+}: {
+ orgId: string;
+ children: (control: {
+ openDialog: (config: SsoConfigTableRow) => void;
+ }) => React.ReactNode;
+}) {
+ return (
+ <DialogController<SsoConfigTableRow>
+ renderDialog={({ state, closeDialog }) => (
+ <DialogContent className="sm:max-w-xl">
+ <SsoConfigDialogContent
+ key={state.domain}
+ orgId={orgId}
+ domain={state.domain}
+ existing={state.config}
+ closeDialog={closeDialog}
+ />
+ </DialogContent>
+ )}
+ >
+ {({ openDialog }) => children({ openDialog })}
+ </DialogController>
+ );
+}
+
+function SsoConfigDialogContent({
+ orgId,
+ domain,
+ existing,
+ closeDialog,
+}: {
+ orgId: string;
+ domain: string;
+ existing: SsoConfigRow | null;
+ closeDialog: () => void;
+}) {
+ const [pendingValues, setPendingValues] = useState<FormValues | null>(null);
+ const utils = api.useUtils();
+
+ const defaultValues = useMemo<FormValues>(() => {
+ const cfg = (existing?.authConfig ?? {}) as Record<string, unknown>;
+ const enterprise = cfg.enterprise as { baseUrl?: string } | undefined;
+ return {
+ authProvider:
+ existing?.authProvider ?? ("okta" as SsoProviderSchema["authProvider"]),
+ authConfig: {
+ clientId: typeof cfg.clientId === "string" ? cfg.clientId : "",
+ clientSecret: "",
+ issuer: typeof cfg.issuer === "string" ? cfg.issuer : "",
+ tenantId: typeof cfg.tenantId === "string" ? cfg.tenantId : "",
+ baseUrl: enterprise?.baseUrl ?? "",
+ name: typeof cfg.name === "string" ? cfg.name : "",
+ idToken: typeof cfg.idToken === "boolean" ? cfg.idToken : true,
+ },
+ };
+ }, [existing]);
+
+ const form = useForm<FormValues>({
+ resolver: zodResolver(formSchema),
+ defaultValues,
+ });
+ const selectedProvider = form.watch("authProvider");
+ const providerSpec = useMemo(
+ () =>
+ SSO_PROVIDERS.find((p) => p.id === selectedProvider) ?? SSO_PROVIDERS[0],
+ [selectedProvider],
+ );
+
+ const callbackUrl = useMemo(() => {
+ if (typeof window === "undefined") return "";
+ return `${window.location.origin}/api/auth/callback/${domain}.${selectedProvider}`;
+ }, [domain, selectedProvider]);
+
+ const saveMutation = api.ssoConfig.save.useMutation({
+ onSuccess: () => {
+ utils.ssoConfig.get.invalidate({ orgId });
+ showSuccessToast({
+ title: existing ? "SSO updated" : "SSO configured",
+ description: `Active for @${domain} within 1 hour.`,
+ });
+ closeDialog();
+ setPendingValues(null);
+ form.reset();
+ },
+ onError: (err) => {
+ showErrorToast(
+ existing ? "Update failed" : "SSO configuration failed",
+ err.message,
+ );
+ },
+ });
+
+ async function handleConfirm() {
+ if (!pendingValues) return;
+ const payload = buildSsoPayload(domain, pendingValues);
+ const parsed = SsoProviderSchema.safeParse(payload);
+ if (!parsed.success) {
+ const firstIssue = parsed.error.issues[0];
+ const schemaPath = firstIssue.path.join(".");
+ // `buildSsoPayload` re-nests `baseUrl` under `enterprise` for
+ // github-enterprise; the strict schema reports errors at the nested
+ // path, but the form field is registered flat. Map back so
+ // `setError` lands on a watched field and the inline message renders.
+ const formPath =
+ schemaPath === "authConfig.enterprise.baseUrl"
+ ? "authConfig.baseUrl"
+ : schemaPath;
+ const formField = formPath.startsWith("authConfig.")
+ ? (formPath as AuthConfigFormField)
+ : "authProvider";
+ form.setError(formField, { message: firstIssue.message });
+ // Defensive fallback: if a future schema path doesn't map cleanly to
+ // a registered form field, surface a toast so the user is never left
+ // with a silently-closing dialog and no feedback.
+ const FORM_FIELDS = [
+ "authProvider",
+ "authConfig.clientId",
+ "authConfig.clientSecret",
+ "authConfig.issuer",
+ "authConfig.tenantId",
+ "authConfig.baseUrl",
+ "authConfig.name",
+ "authConfig.idToken",
+ ];
+ if (!FORM_FIELDS.includes(formField)) {
+ showErrorToast(
+ existing ? "Update failed" : "SSO configuration failed",
+ firstIssue.message,
+ );
+ }
+ return;
+ }
+ await saveMutation.mutateAsync({ orgId, payload: parsed.data });
+ }
+
+ return (
+ <ConfirmationDialogController
+ title={
+ existing
+ ? `Replace SSO for @${domain}?`
+ : `Activate SSO for @${domain}?`
+ }
+ text={`Saving will activate SSO for @${domain} within 1 hour. Every user at that domain will be redirected to your identity provider on sign-in - they will not be able to use Google, GitHub, password, or any other method until SSO is deleted.${existing ? " The new credentials will replace the active configuration." : ""} Tip: sign in via the new SSO in a second browser to confirm it works before closing this tab.`}
+ confirmLabel={existing ? "Replace" : "Activate SSO"}
+ variant="default"
+ loading={saveMutation.isPending}
+ onConfirm={handleConfirm}
+ >
+ {({ openDialog }) => (
+ <>
+ <DialogHeader>
+ <DialogTitle>
+ {existing
+ ? `Update SSO for ${domain}`
+ : `Configure SSO for ${domain}`}
+ </DialogTitle>
+ </DialogHeader>
+ <Form {...form}>
+ <form
+ onSubmit={form.handleSubmit((values) => {
+ setPendingValues(values);
+ openDialog();
+ })}
+ >
+ <DialogBody className="space-y-4">
+ <FormField
+ control={form.control}
+ name="authProvider"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Provider</FormLabel>
+ <FormControl>
+ <SelectInput
+ value={field.value}
+ onValueChange={field.onChange}
+ placeholder="Select an SSO provider"
+ options={SSO_PROVIDERS.map((provider) => ({
+ value: provider.id,
+ label: provider.label,
+ }))}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <CallbackUrlPanel callbackUrl={callbackUrl} />
+
+ {providerSpec.fields.includes("name") ? (
+ <FormField
+ control={form.control}
+ name="authConfig.name"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Display Name</FormLabel>
+ <FormControl>
+ <Input placeholder="Acme SSO" {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ ) : null}
+
+ <FormField
+ control={form.control}
+ name="authConfig.clientId"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Client ID</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
+ name="authConfig.clientSecret"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Client Secret</FormLabel>
+ <FormControl>
+ <Input
+ type="password"
+ autoComplete="off"
+ placeholder={
+ existing ? "Re-enter to update" : undefined
+ }
+ {...field}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ {providerSpec.fields.includes("issuer") ? (
+ <FormField
+ control={form.control}
+ name="authConfig.issuer"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Issuer URL</FormLabel>
+ <FormControl>
+ <Input
+ placeholder="https://example.okta.com"
+ {...field}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ ) : null}
+
+ {providerSpec.fields.includes("tenantId") ? (
+ <FormField
+ control={form.control}
+ name="authConfig.tenantId"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Tenant ID</FormLabel>
+ <FormControl>
+ <Input {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ ) : null}
+
+ {providerSpec.fields.includes("baseUrl") ? (
+ <FormField
+ control={form.control}
+ name="authConfig.baseUrl"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Base URL</FormLabel>
+ <FormControl>
+ <Input
+ placeholder="https://github.acme.com"
+ {...field}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ ) : null}
+
+ {selectedProvider === "custom" ? (
+ <>
+ <FormField
+ control={form.control}
+ name="authConfig.idToken"
+ render={({ field }) => (
+ <FormItem className="flex flex-row items-start space-y-0 space-x-3 rounded-md border p-4">
+ <FormControl>
+ <Checkbox
+ checked={field.value ?? false}
+ onCheckedChange={(checked) =>
+ field.onChange(checked === true)
+ }
+ />
+ </FormControl>
+ <div className="space-y-1 leading-none">
+ <FormLabel>
+ Use id_token claims only (skip userinfo)
+ </FormLabel>
+ <FormDescription>
+ Leave off for IdPs that release email only via the
+ userinfo endpoint.
+ </FormDescription>
+ </div>
+ </FormItem>
+ )}
+ />
+ </>
+ ) : null}
+ </DialogBody>
+ <DialogFooter>
+ <Button type="button" variant="ghost" onClick={closeDialog}>
+ Cancel
+ </Button>
+ <Button type="submit" loading={saveMutation.isPending}>
+ Save
+ </Button>
+ </DialogFooter>
+ </form>
+ </Form>
+ </>
+ )}
+ </ConfirmationDialogController>
+ );
+}
+
+function CallbackUrlPanel({ callbackUrl }: { callbackUrl: string }) {
+ const columns: LangfuseColumnDef<{ url: string }>[] = [
+ {
+ accessorKey: "url",
+ header: "URL",
+ cell: ({ getValue }) => (
+ <CopyableCallbackUrl value={getValue<string>()} />
+ ),
+ },
+ ];
+
+ return (
+ <div>
+ <p className="mb-2 text-sm font-bold">Callback URL</p>
+ <Card className="overflow-hidden">
+ <SimpleDataTable
+ columns={columns}
+ data={[{ url: callbackUrl }]}
+ isLoading={false}
+ noResults={null}
+ />
+ </Card>
+ <p className="text-muted-foreground mt-2 text-xs">
+ Add this URL as an authorized redirect URI in your identity provider.
+ </p>
+ </div>
+ );
+}
+
+function CopyableCallbackUrl({ value }: { value: string }) {
+ const { copy, isCopied } = useCopyToClipboard();
+
+ return (
+ <div className="relative pr-8 font-mono break-all">
+ <span>{value}</span>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="absolute top-1/2 right-0 -translate-y-1/2"
+ title="Copy to clipboard"
+ aria-label="Copy to clipboard"
+ onClick={async (event) => {
+ event.preventDefault();
+ const button = event.currentTarget;
+ await copy(value).catch(() => undefined);
+ button.focus();
+ }}
+ >
+ {isCopied ? (
+ <Check className="h-3 w-3" />
+ ) : (
+ <Copy className="h-3 w-3" />
+ )}
+ </Button>
+ </div>
+ );
+}
+
+// Build the SsoProviderSchema-shaped payload from the flat form values.
+// Handles the nested github-enterprise.enterprise.baseUrl shape.
+function buildSsoPayload(domain: string, values: FormValues) {
+ const { authProvider, authConfig } = values;
+ // allowDangerousEmailAccountLinking is required for SSO migration of
+ // existing accounts. Cross-tenant misuse is prevented by the DNS-verified
+ // domain check at save time + the runtime domain enforcement in
+ // web/src/server/auth.ts.
+ const base = {
+ clientId: authConfig.clientId,
+ clientSecret: authConfig.clientSecret,
+ allowDangerousEmailAccountLinking: true,
+ };
+
+ switch (authProvider) {
+ case "google":
+ case "github":
+ case "gitlab":
+ return { domain, authProvider, authConfig: base };
+ case "github-enterprise":
+ return {
+ domain,
+ authProvider,
+ authConfig: {
+ ...base,
+ enterprise: { baseUrl: authConfig.baseUrl ?? "" },
+ },
+ };
+ case "azure-ad":
+ return {
+ domain,
+ authProvider,
+ authConfig: { ...base, tenantId: authConfig.tenantId ?? "" },
+ };
+ case "auth0":
+ case "okta":
+ case "authentik":
+ case "onelogin":
+ case "cognito":
+ case "keycloak":
+ case "jumpcloud":
+ return {
+ domain,
+ authProvider,
+ authConfig: { ...base, issuer: authConfig.issuer ?? "" },
+ };
+ case "custom":
+ return {
+ domain,
+ authProvider,
+ authConfig: {
+ ...base,
+ issuer: authConfig.issuer ?? "",
+ name: authConfig.name ?? "",
+ idToken: authConfig.idToken ?? true,
+ },
+ };
+ default:
+ return { domain, authProvider, authConfig: base };
+ }
+}
diff --git a/web/src/ee/features/sso-settings/components/SsoConfigsTable/ConnectedSsoConfigsTable.tsx b/web/src/ee/features/sso-settings/components/SsoConfigsTable/ConnectedSsoConfigsTable.tsx
new file mode 100644
index 0000000000..d78933a221
--- /dev/null
+++ b/web/src/ee/features/sso-settings/components/SsoConfigsTable/ConnectedSsoConfigsTable.tsx
@@ -0,0 +1,59 @@
+import { useMemo } from "react";
+import { api } from "@/src/utils/api";
+import { Card } from "@/src/components/ui/card";
+import { DeleteSsoConfigDialogController } from "../DeleteSsoConfigDialogController";
+import { SsoConfigDialogController } from "../SsoConfigDialogController";
+import {
+ SsoConfigsTable,
+ type SsoConfigRow,
+ type SsoConfigTableRow,
+} from "./SsoConfigsTable";
+
+export function ConnectedSsoConfigsTable({ orgId }: { orgId: string }) {
+ const verifiedDomainsQuery = api.verifiedDomain.list.useQuery({ orgId });
+ const ssoConfigsQuery = api.ssoConfig.get.useQuery({ orgId });
+
+ const verifiedDomains = useMemo(
+ () =>
+ verifiedDomainsQuery.data?.filter(
+ (domain) => domain.verifiedAt != null,
+ ) ?? [],
+ [verifiedDomainsQuery.data],
+ );
+ const configByDomain = useMemo(() => {
+ const map = new Map<string, SsoConfigRow>();
+ ssoConfigsQuery.data?.forEach((config) => map.set(config.domain, config));
+ return map;
+ }, [ssoConfigsQuery.data]);
+
+ const data: SsoConfigTableRow[] = verifiedDomains.map((domain) => ({
+ domain: domain.domain,
+ config: configByDomain.get(domain.domain) ?? null,
+ }));
+
+ if (verifiedDomains.length === 0) {
+ return (
+ <Card className="overflow-hidden">
+ <p className="text-muted-foreground px-6 py-12 text-center text-sm">
+ Verify a domain in the section above to configure SSO for it.
+ </p>
+ </Card>
+ );
+ }
+
+ return (
+ <SsoConfigDialogController orgId={orgId}>
+ {({ openDialog: openConfigDialog }) => (
+ <DeleteSsoConfigDialogController orgId={orgId}>
+ {({ openDialog: openDeleteDialog }) => (
+ <SsoConfigsTable
+ data={data}
+ onConfigure={openConfigDialog}
+ onDelete={openDeleteDialog}
+ />
+ )}
+ </DeleteSsoConfigDialogController>
+ )}
+ </SsoConfigDialogController>
+ );
+}
diff --git a/web/src/ee/features/sso-settings/components/SsoConfigsTable/SsoConfigsTable.stories.tsx b/web/src/ee/features/sso-settings/components/SsoConfigsTable/SsoConfigsTable.stories.tsx
new file mode 100644
index 0000000000..9db4d3ccf9
--- /dev/null
+++ b/web/src/ee/features/sso-settings/components/SsoConfigsTable/SsoConfigsTable.stories.tsx
@@ -0,0 +1,25 @@
+import { fn } from "storybook/test";
+import preview from "../../../../../../.storybook/preview";
+import { SsoConfigsTable } from "./SsoConfigsTable";
+
+const meta = preview.meta({ component: SsoConfigsTable });
+
+export const Default = meta.story({
+ args: {
+ data: [
+ { domain: "example.com", config: null },
+ {
+ domain: "company.com",
+ config: {
+ domain: "company.com",
+ authProvider: "okta",
+ authConfig: null,
+ createdAt: new Date("2026-09-01"),
+ updatedAt: new Date("2026-09-20"),
+ },
+ },
+ ],
+ onConfigure: fn(),
+ onDelete: fn(),
+ },
+});
diff --git a/web/src/ee/features/sso-settings/components/SsoConfigsTable/SsoConfigsTable.tsx b/web/src/ee/features/sso-settings/components/SsoConfigsTable/SsoConfigsTable.tsx
new file mode 100644
index 0000000000..0f343b8819
--- /dev/null
+++ b/web/src/ee/features/sso-settings/components/SsoConfigsTable/SsoConfigsTable.tsx
@@ -0,0 +1,107 @@
+import { useMemo } from "react";
+import { TrashIcon } from "lucide-react";
+import { SettingsTable } from "@/src/components/SettingsTable/SettingsTable";
+import { createBadgeTableColumn } from "@/src/components/design-system/table/columns/createBadgeTableColumn";
+import { createButtonTableColumn } from "@/src/components/design-system/table/columns/createButtonTableColumn";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+
+export type SsoConfigRow = {
+ domain: string;
+ authProvider: string;
+ authConfig: Record<string, unknown> | null;
+ createdAt: Date;
+ updatedAt: Date;
+};
+
+export type SsoConfigTableRow = {
+ domain: string;
+ config: SsoConfigRow | null;
+};
+
+const providerLabels: Record<string, string> = {
+ google: "Google",
+ github: "GitHub",
+ "github-enterprise": "GitHub Enterprise",
+ gitlab: "GitLab",
+ auth0: "Auth0",
+ okta: "Okta",
+ authentik: "Authentik",
+ onelogin: "OneLogin",
+ "azure-ad": "Azure AD / Entra ID",
+ cognito: "AWS Cognito",
+ keycloak: "Keycloak",
+ jumpcloud: "JumpCloud",
+ custom: "Custom OIDC",
+};
+
+export function SsoConfigsTable({
+ data,
+ onConfigure,
+ onDelete,
+}: {
+ data: SsoConfigTableRow[];
+ onConfigure: (row: SsoConfigTableRow) => void;
+ onDelete: (domain: string) => void;
+}) {
+ const columns = useMemo<LangfuseColumnDef<SsoConfigTableRow>[]>(
+ () => [
+ createTextTableColumn<SsoConfigTableRow>({
+ accessorKey: "domain",
+ header: "Domain",
+ }),
+ createBadgeTableColumn<SsoConfigTableRow>({
+ id: "provider",
+ accessorFn: (row) => row.config?.authProvider ?? "Not configured",
+ header: "Provider",
+ getBadge: (provider) =>
+ provider === "Not configured"
+ ? { value: provider, variant: "secondary" }
+ : {
+ value: providerLabels[provider] ?? provider,
+ variant: "default",
+ },
+ }),
+ createTextTableColumn<SsoConfigTableRow, Date>({
+ accessorFn: (row) => row.config?.updatedAt,
+ id: "updatedAt",
+ header: "Updated",
+ hideBelowMd: true,
+ mapValue: (date) => date?.toLocaleDateString(),
+ nullValue: "—",
+ }),
+ createButtonTableColumn<SsoConfigTableRow, string>({
+ accessorFn: (row) => row.domain,
+ id: "configure",
+ header: "",
+ getButton: ({ row }) => ({
+ text: row.original.config ? "Update" : "Configure SSO",
+ onClick: () => onConfigure(row.original),
+ }),
+ }),
+ ],
+ [onConfigure],
+ );
+
+ return (
+ <SettingsTable
+ tableName="SSO configurations"
+ columns={columns}
+ actions={(row) =>
+ row.config
+ ? [
+ {
+ id: "delete",
+ type: "item",
+ title: `Delete SSO for ${row.domain}`,
+ icon: TrashIcon,
+ variant: "destructive",
+ onClick: () => onDelete(row.domain),
+ },
+ ]
+ : []
+ }
+ data={{ status: "success", data }}
+ />
+ );
+}