Forward verified bearer identity to backend
This commit is contained in:
@@ -343,7 +343,7 @@ export function runTests() {
|
||||
assert(
|
||||
backendAuthSource.includes("headers.set(FORWARDED_SUPABASE_USER_ID_HEADER") &&
|
||||
backendAuthSource.includes("headers.set(FORWARDED_SUPABASE_EMAIL_HEADER") &&
|
||||
backendAuthSource.indexOf("headers.set(FORWARDED_SUPABASE_USER_ID_HEADER") >
|
||||
backendAuthSource.lastIndexOf("headers.set(FORWARDED_SUPABASE_USER_ID_HEADER") >
|
||||
backendAuthSource.indexOf("const sessionUser = session?.user"),
|
||||
"backend proxy must forward Supabase session user id/email with the backend token so Python can skip duplicate /auth/v1/user validation",
|
||||
);
|
||||
|
||||
@@ -37,4 +37,17 @@ export function runTests() {
|
||||
helperSource.includes('result.set("Content-Type", "application/json")'),
|
||||
"backend auth must expose a safe JSON header builder",
|
||||
);
|
||||
|
||||
assert(
|
||||
helperSource.includes("getVerifiedBearerIdentity") &&
|
||||
helperSource.includes("/auth/v1/user") &&
|
||||
helperSource.includes("apikey: anonKey") &&
|
||||
helperSource.includes("incomingAuth") &&
|
||||
helperSource.includes("const identity = await getVerifiedBearerIdentity(incomingAuth)") &&
|
||||
helperSource.includes("headers.set(FORWARDED_SUPABASE_USER_ID_HEADER, identity.userId)") &&
|
||||
helperSource.includes("headers.set(FORWARDED_SUPABASE_EMAIL_HEADER, identity.email)") &&
|
||||
helperSource.includes("authUserId: identity?.userId || null") &&
|
||||
helperSource.includes("authEmail: identity?.email || null"),
|
||||
"backend auth helper must verify incoming Supabase bearer tokens and forward trusted user identity headers to backend services",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user