🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(sso): omit IdP-reported issuer from discovery errors (#17880)
Mark Salpeterdcf855a4d333
diff --git a/web/src/__tests__/server/ssoConfigRouter.servertest.ts b/web/src/__tests__/server/ssoConfigRouter.servertest.tsindex ca26e8f7c9..6c401847cd 100644--- a/web/src/__tests__/server/ssoConfigRouter.servertest.ts+++ b/web/src/__tests__/server/ssoConfigRouter.servertest.ts@@ -798,18 +798,26 @@ describe("ssoConfigRouter.save — IdP discovery validation", () => {const { org, caller } = await prepare();const domain = `discovery-mismatch-${uuidv4().slice(0, 8)}.com`;await addVerifiedDomain(org.id, domain);+ // Chosen by the remote IdP. Must not be copied into the client error.+ const reportedIssuer =+ "https://idp-reported.invalid/issuer-must-not-appear-in-the-error";fetchMock.mockResolvedValueOnce(discoveryResponse({- issuer: "https://different.example.com",- authorization_endpoint: "https://different.example.com/authorize",- token_endpoint: "https://different.example.com/oauth/token",- jwks_uri: "https://different.example.com/.well-known/jwks.json",+ issuer: reportedIssuer,+ authorization_endpoint: "https://example.com/authorize",+ token_endpoint: "https://example.com/oauth/token",+ jwks_uri: "https://example.com/.well-known/jwks.json",}),);await expect(caller.ssoConfig.save({ orgId: org.id, payload: samplePayload(domain) }),- ).rejects.toMatchObject({ code: "PRECONDITION_FAILED" });+ ).rejects.toSatisfy((error: { code?: string; message?: string }) => {+ expect(error.code).toBe("PRECONDITION_FAILED");+ expect(error.message).toContain("did not report the configured issuer");+ expect(error.message).not.toContain(reportedIssuer);+ return true;+ });});it("accepts a discovery doc whose issuer matches modulo trailing slash", async () => {diff --git a/web/src/ee/features/multi-tenant-sso/validateSsoConfig.ts b/web/src/ee/features/multi-tenant-sso/validateSsoConfig.tsindex 38c72a54fe..50be0f5643 100644--- a/web/src/ee/features/multi-tenant-sso/validateSsoConfig.ts+++ b/web/src/ee/features/multi-tenant-sso/validateSsoConfig.ts@@ -183,11 +183,14 @@ function validateDiscoveryIssuer(// OIDC Discovery §3: the doc's issuer must match the URL it was fetched from.// Trailing slashes trimmed on both sides — Auth0 and friends serve one.+ // The returned issuer is chosen by the remote IdP, so it stays out of the+ // client error. The discovery URL prefix already names what we fetched.const returnedIssuer = stripTrailingSlash(doc.issuer);if (returnedIssuer !== expectedIssuer) {throw new TRPCError({code: "PRECONDITION_FAILED",- message: `reported issuer "${doc.issuer}" but we expected "${expectedIssuer}". Check the issuer URL matches exactly.`,+ message:+ "did not report the configured issuer. Check the issuer URL matches exactly.",});}}