Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

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