Skip to content

Commit 03fdfb0

Browse files
jsell-rhclaude
andcommitted
fix(auth): enable dual-auth in SSO mode for E2E tests and API clients
buildForwardHeadersSSO now falls back to Bearer token from request when no SSO session cookie exists. This enables: - SSO users: session cookie → JWT forwarded - E2E tests / API clients: Bearer token in request → forwarded directly Also adds Keycloak to wait-for-ready.sh to prevent race conditions where frontend starts before Keycloak is ready. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent da361b8 commit 03fdfb0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

components/frontend/src/lib/auth.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,15 @@ async function buildForwardHeadersSSO(request: Request, extra?: Record<string, s
172172
'Accept': 'application/json',
173173
};
174174

175-
const accessToken = await getAccessToken();
175+
// Try session token first (browser users with SSO cookie)
176+
let accessToken = await getAccessToken();
177+
178+
// Fall back to Bearer token from request (E2E tests, API clients, service accounts)
179+
// This enables dual-auth: SSO sessions + direct Bearer token authentication
180+
if (!accessToken) {
181+
accessToken = extractAccessToken(request) || undefined;
182+
}
183+
176184
if (accessToken) {
177185
headers['Authorization'] = `Bearer ${accessToken}`;
178186

e2e/scripts/wait-for-ready.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ kubectl wait --for=condition=available --timeout=300s \
3434
deployment/minio \
3535
-n ambient-code 2>/dev/null || echo "⚠️ MinIO not deployed (S3 persistence disabled)"
3636

37+
# Wait for Keycloak (SSO/OIDC provider - frontend needs it for SSO mode)
38+
echo "⏳ Waiting for keycloak..."
39+
kubectl wait --for=condition=available --timeout=300s \
40+
deployment/keycloak \
41+
-n ambient-code 2>/dev/null || echo "⚠️ Keycloak not deployed (SSO disabled)"
42+
3743
echo ""
3844
echo "✅ All pods are ready!"
3945
echo ""

0 commit comments

Comments
 (0)