diff --git a/src/app/app.ts b/src/app/app.ts index f488385..910aa7a 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -20,3 +20,7 @@ export function appIdpEntityId(app: App): string { export function appIdpRedirectUrl(app: App): string { return `https://${process.env.DUMMYIDP_CUSTOM_DOMAIN || process.env.VERCEL_URL}/apps/${app.id}/sso`; } + +export function appIdpMetadataUrl(app: App): string { + return `https://${process.env.DUMMYIDP_CUSTOM_DOMAIN || process.env.VERCEL_URL}/apps/${app.id}/metadata`; +} diff --git a/src/app/apps/[id]/metadata/route.ts b/src/app/apps/[id]/metadata/route.ts new file mode 100644 index 0000000..48464a0 --- /dev/null +++ b/src/app/apps/[id]/metadata/route.ts @@ -0,0 +1,42 @@ +import { NextRequest, NextResponse } from "next/server"; +import { getApp } from "@/app/actions"; +import { appIdpEntityId, appIdpRedirectUrl } from "@/app/app"; +import { INSECURE_PUBLIC_CERTIFICATE } from "@/lib/insecure-cert"; + +export async function GET( + req: NextRequest, + { params }: { params: { id: string } }, +) { + const prefix = "-----BEGIN CERTIFICATE-----\n"; + const suffix = "-----END CERTIFICATE-----"; + const certNoPEMHeaders = INSECURE_PUBLIC_CERTIFICATE.substring( + 0, + INSECURE_PUBLIC_CERTIFICATE.length - suffix.length, + ) + .substring(prefix.length) + .replaceAll("\n", ""); + + const app = await getApp(params.id); + return new NextResponse( + ` + + + + + + ${certNoPEMHeaders} + + + + urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress + + +`, + { + headers: { + "content-type": "application/xml;charset=ISO-8859-1", + "x-content-type-options": "nosniff", + }, + }, + ); +} diff --git a/src/app/apps/[id]/page.tsx b/src/app/apps/[id]/page.tsx index 429d157..baaf1ac 100644 --- a/src/app/apps/[id]/page.tsx +++ b/src/app/apps/[id]/page.tsx @@ -19,7 +19,11 @@ import { } from "@/components/ui/breadcrumb"; import { DocsLink } from "@/components/DocsLink"; import { Label } from "@/components/ui/label"; -import { appIdpEntityId, appIdpRedirectUrl } from "@/app/app"; +import { + appIdpEntityId, + appIdpMetadataUrl, + appIdpRedirectUrl, +} from "@/app/app"; import { useMemo } from "react"; import { ArrowDownToLineIcon } from "lucide-react"; import { SPSettingsForm } from "@/app/apps/[id]/SPSettingsForm"; @@ -95,6 +99,13 @@ export default async function Page({ params }: { params: { id: string } }) { + + IDP Metadata URL + + {appIdpMetadataUrl(app)} + + + IDP Entity ID