diff --git a/apps/login/package.json b/apps/login/package.json index b089af96d..7ee6f843c 100644 --- a/apps/login/package.json +++ b/apps/login/package.json @@ -29,6 +29,7 @@ "clsx": "^2.1.1", "copy-to-clipboard": "^3.3.3", "deepmerge": "^4.3.1", + "escape-html": "^1.0.3", "lucide-react": "^0.562.0", "moment": "^2.30.1", "next": "15.5.9", @@ -52,11 +53,12 @@ "@playwright/test": "^1.57.0", "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.1", + "@types/escape-html": "^1.0.4", "@types/node": "^22.19.3", "@types/react": "19.2.7", "@types/react-dom": "19.2.3", - "@types/uuid": "^10.0.0", "@types/tinycolor2": "^1.4.6", + "@types/uuid": "^10.0.0", "@typescript-eslint/eslint-plugin": "^8.52.0", "@typescript-eslint/parser": "^8.52.0", "@vercel/git-hooks": "1.0.0", diff --git a/apps/login/src/app/(login)/idp/[provider]/complete-registration/page.tsx b/apps/login/src/app/(login)/idp/[provider]/complete-registration/page.tsx index dbf3e5abf..9741f4bba 100644 --- a/apps/login/src/app/(login)/idp/[provider]/complete-registration/page.tsx +++ b/apps/login/src/app/(login)/idp/[provider]/complete-registration/page.tsx @@ -18,10 +18,9 @@ export default async function CompleteRegistrationPage(props: { const _headers = await headers(); const { serviceConfig } = getServiceConfig(_headers); - const branding = await getBrandingSettings({ serviceConfig, organization, - }); + const branding = await getBrandingSettings({ serviceConfig, organization }); - if (!id || !token || !idpId || !organization || !idpUserId || !idpUserName) { + if (!id || !token || !idpId || !organization || !idpUserId) { throw new Error("Missing required parameters"); } diff --git a/apps/login/src/app/(login)/saml-post/route.ts b/apps/login/src/app/(login)/saml-post/route.ts deleted file mode 100644 index a2061a18e..000000000 --- a/apps/login/src/app/(login)/saml-post/route.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { getSAMLFormCookie } from "@/lib/saml"; -import { NextRequest, NextResponse } from "next/server"; - -export async function GET(request: NextRequest) { - const searchParams = request.nextUrl.searchParams; - const url = searchParams.get("url"); - const id = searchParams.get("id"); - - if (!url) { - return new NextResponse("Missing url parameter", { status: 400 }); - } - - if (!id) { - return new NextResponse("Missing id parameter", { status: 400 }); - } - - const formData = await getSAMLFormCookie(id); - - const formDataParsed = formData ? JSON.parse(formData) : null; - - if (!formDataParsed) { - return new NextResponse("SAML form data not found", { status: 404 }); - } - - // Generate hidden input fields for all key-value pairs in formDataParsed - const hiddenInputs = Object.entries(formDataParsed) - .map( - ([key, value]) => - ``, - ) - .join("\n "); - - // Respond with an HTML form that auto-submits via POST - const html = ` - -
- - - - `; - return new NextResponse(html, { - headers: { "Content-Type": "text/html" }, - }); -} diff --git a/apps/login/src/components/auto-submit-form.tsx b/apps/login/src/components/auto-submit-form.tsx new file mode 100644 index 000000000..be7504de0 --- /dev/null +++ b/apps/login/src/components/auto-submit-form.tsx @@ -0,0 +1,29 @@ +"use client"; + +import { useEffect, useRef } from "react"; + +type Props = { + url: string; + fields: Record