mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
* fix: OIDC 502 on sign-in from oversized id_token cookie (#12986) Storing the full OIDC id_token in the `oidcIdToken` cookie inflated the sign-in response headers enough to exceed reverse proxy buffers, causing a 502 Bad Gateway. Store the id_token server-side in Redis keyed by a short session identifier and keep only that identifier in the cookie, preserving spec-compliant RP-initiated logout via `id_token_hint`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix: Make OIDC logout token persistence best-effort A Redis failure when storing or reading the logout id_token_hint should not block sign-in or logout; fall back to omitting the hint instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * docs * refactor: Extract portable LogoutTokenStore for provider logout hints Move the cookie-referenced, Redis-backed logout token persistence out of the OIDC router into a provider-agnostic `LogoutTokenStore`. Any auth provider that supports provider-initiated logout can now persist and consume a logout hint via `new LogoutTokenStore(providerId)` without duplicating the cookie/Redis/error handling. The OIDC-specific end-session URL construction stays in the router. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
66 lines
2.3 KiB
TypeScript
66 lines
2.3 KiB
TypeScript
import Redis from "@server/storage/redis";
|
|
import { RedisPrefixHelper } from "@server/utils/RedisPrefixHelper";
|
|
import { getTestServer } from "@server/test/support";
|
|
|
|
const server = getTestServer();
|
|
|
|
describe("oidc", () => {
|
|
it("should pass query params along with auth redirect", async () => {
|
|
const res = await server.get("/auth/oidc?myParam=someParam", {
|
|
redirect: "manual",
|
|
});
|
|
expect(res.headers.get("location")).not.toBeNull();
|
|
const redirectLocation = new URL(res.headers.get("location")!);
|
|
expect(res.status).toEqual(302);
|
|
expect(redirectLocation.searchParams.get("myParam")).toEqual("someParam");
|
|
});
|
|
|
|
describe("logout", () => {
|
|
it("should redirect to the provider with a spec-compliant logout request", async () => {
|
|
const res = await server.get("/auth/oidc.logout", {
|
|
redirect: "manual",
|
|
});
|
|
expect(res.status).toEqual(302);
|
|
const redirectLocation = new URL(res.headers.get("location")!);
|
|
expect(redirectLocation.origin + redirectLocation.pathname).toEqual(
|
|
"http://localhost/logout"
|
|
);
|
|
expect(redirectLocation.searchParams.get("client_id")).toEqual(
|
|
"client-id"
|
|
);
|
|
expect(
|
|
redirectLocation.searchParams.get("post_logout_redirect_uri")
|
|
).toEqual("http://localhost:3000");
|
|
});
|
|
|
|
it("should include the id_token_hint when present", async () => {
|
|
const sessionId = "test-session-id";
|
|
await Redis.defaultClient.set(
|
|
RedisPrefixHelper.getLogoutTokenKey("oidc", sessionId),
|
|
"fake-id-token"
|
|
);
|
|
|
|
const res = await server.get("/auth/oidc.logout", {
|
|
redirect: "manual",
|
|
headers: {
|
|
Cookie: `oidcSession=${sessionId}`,
|
|
},
|
|
});
|
|
expect(res.status).toEqual(302);
|
|
const redirectLocation = new URL(res.headers.get("location")!);
|
|
expect(redirectLocation.searchParams.get("id_token_hint")).toEqual(
|
|
"fake-id-token"
|
|
);
|
|
expect(res.headers.get("set-cookie")).toContain(
|
|
"oidcSession=; path=/auth/oidc.logout;"
|
|
);
|
|
// The token is consumed from the server-side store on logout.
|
|
expect(
|
|
await Redis.defaultClient.get(
|
|
RedisPrefixHelper.getLogoutTokenKey("oidc", sessionId)
|
|
)
|
|
).toBeNull();
|
|
});
|
|
});
|
|
});
|