diff --git a/keep-ui/shared/lib/__tests__/oauth2proxy-auth.test.ts b/keep-ui/shared/lib/__tests__/oauth2proxy-auth.test.ts index 4342993be6..82f1b22fcd 100644 --- a/keep-ui/shared/lib/__tests__/oauth2proxy-auth.test.ts +++ b/keep-ui/shared/lib/__tests__/oauth2proxy-auth.test.ts @@ -222,4 +222,28 @@ describe("authorizeOAuth2Proxy", () => { expect(user!.id).toBe("email@example.com"); }); + + it("returns tenantId matching backend SINGLE_TENANT_UUID", () => { + const headers = makeHeaders({ + "x-forwarded-user": "Test User", + "x-forwarded-email": "test@example.com", + }); + + const user = authorizeOAuth2Proxy(headers, defaultConfig); + + expect(user).not.toBeNull(); + expect(user!.tenantId).toBe("keep"); + }); + + it("never returns undefined tenantId for a valid user", () => { + const headers = makeHeaders({ + "x-forwarded-email": "user@example.com", + }); + + const user = authorizeOAuth2Proxy(headers, defaultConfig); + + expect(user).not.toBeNull(); + expect(user!.tenantId).toBeDefined(); + expect(user!.tenantId).not.toBe("undefined"); + }); }); diff --git a/keep-ui/shared/lib/oauth2proxy-auth.ts b/keep-ui/shared/lib/oauth2proxy-auth.ts index 8fe146edfb..e03f264c51 100644 --- a/keep-ui/shared/lib/oauth2proxy-auth.ts +++ b/keep-ui/shared/lib/oauth2proxy-auth.ts @@ -51,5 +51,6 @@ export function authorizeOAuth2Proxy( email: emailValue || userValue || "oauth2proxy-user", accessToken: accessToken || `oauth2proxy:${identity}`, role: groups || undefined, + tenantId: "keep", }; }