| 1 | import { ssoAddresses } from "@g1t/contracts"; |
| 2 | |
| 3 | import type { Route } from "./+types/auth-sso-metadata"; |
| 4 | import { sso } from "../lib/sso.server"; |
| 5 | |
| 6 | /** |
| 7 | * g1t's SAML service provider metadata for a workspace, for its identity |
| 8 | * provider to read: the entity id (this address) and where to post the |
| 9 | * response. The same for everyone; it says nothing about the workspace. |
| 10 | */ |
| 11 | export async function loader({ request, params }: Route.LoaderArgs) { |
| 12 | const addresses = ssoAddresses(new URL(request.url).origin, params.owner); |
| 13 | const xml = await sso.metadata(addresses.entityId, addresses.acsUrl); |
| 14 | return new Response(xml, { |
| 15 | headers: { |
| 16 | "content-type": "application/samlmetadata+xml; charset=utf-8", |
| 17 | "cache-control": "public, max-age=3600", |
| 18 | "content-disposition": `inline; filename="g1t-${params.owner.toLowerCase()}-metadata.xml"`, |
| 19 | }, |
| 20 | }); |
| 21 | } |