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, redirect } from "react-router";
2
3import type { Route } from "./+types/auth-sso-saml";
4import { page } from "../lib/meta";
5import { clearErrorCookie, readErrorCookie } from "../lib/sso";
6import { SsoProblem } from "./auth-sso";
7
8export function meta({ params, ...args }: Route.MetaArgs) {
9 return page(args, { title: `Single sign-on · ${params.owner} · g1t` });
10}
11
12/**
13 * The assertion consumer service, as a page: the provider's POST is
14 * answered by the Worker (workers/sso-saml.ts), which comes back here with
15 * why it did not work. Opened by itself, it starts again.
16 */
17export async function loader({ request, params }: Route.LoaderArgs) {
18 const slug = params.owner.toLowerCase();
19 const error = readErrorCookie(request.headers.get("cookie"));
20 if (!error) throw redirect(`/auth/sso/${slug}`);
21 return data({ slug, error }, { headers: { "set-cookie": clearErrorCookie() } });
22}
23
24export default function SsoSaml({ loaderData }: Route.ComponentProps) {
25 return <SsoProblem slug={loaderData.slug} error={loaderData.error} />;
26}