@@ -222,9 +222,10 @@ Add these to your `.env` file:
222222
223223| Variable | Example | Description |
224224| ----------| ---------| -------------|
225- | ` OIDC_ISSUER ` | ` https://keycloak.example.com/realms/pki ` | OIDC provider base URL |
225+ | ` OIDC_ISSUER ` | ` https://keycloak.example.com/realms/pki ` | OIDC provider base URL (must match token ` iss ` claim) |
226226| ` OIDC_AUDIENCE ` | ` pki-web,pki-service ` | Expected audience claim(s), comma-separated |
227227| ` OIDC_ROLES_CLAIM ` | ` realm_access.roles ` | JWT path to roles (provider-specific) |
228+ | ` OIDC_DISCOVERY_BASE_URL ` | _ (optional)_ | Override URL for fetching OIDC discovery (for Docker networking) |
228229
229230** Provider-specific issuer URLs:**
230231- ** Keycloak** : ` https://keycloak.example.com/realms/your-realm `
@@ -386,21 +387,54 @@ Available tags:
386387
387388PKI Manager includes comprehensive E2E tests for Role-Based Access Control (RBAC). Tests can run against a local Docker environment or production.
388389
390+ # ## E2E Architecture
391+
392+ ```
393+ ┌─────────────────────────────────────────────────────────────────────┐
394+ │ Host Machine │
395+ │ ┌────────────────┐ │
396+ │ │ Playwright │ ──────────────────┐ │
397+ │ │ Test Runner │ │ │
398+ │ └────────────────┘ ▼ │
399+ │ │ localhost:8080 (Frontend) │
400+ │ │ localhost:3000 (Backend API) │
401+ │ │ localhost:8180 (Keycloak) │
402+ │ │ │ │
403+ │ ═══════╪═════════════════════════════╪═════════════════════════ │
404+ │ │ Docker Network │ │
405+ │ ▼ (pki-e2e-network) │
406+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
407+ │ │ Frontend │ │ Backend │ │ Keycloak │ │ KMS │ │
408+ │ │ (nginx) │ │ (Node.js) │ │ (OIDC) │ │ (Cosmian) │ │
409+ │ │ :8080 │──│ :3000 │──│ :8080 │ │ :9998 │ │
410+ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │
411+ │ │ │
412+ │ └──── OIDC_DISCOVERY_BASE_URL ────┘ │
413+ │ (keycloak:8080) │
414+ └─────────────────────────────────────────────────────────────────────┘
415+ ```
416+
417+ The backend uses `OIDC_DISCOVERY_BASE_URL` to fetch OIDC configuration from the Docker network (`keycloak:8080`) while validating tokens against the issuer URL that browsers use (`localhost:8180`).
418+
389419### Local E2E Testing (Recommended)
390420
391421The `docker-compose.e2e.yml` provides a complete isolated environment for testing:
392422
393423```bash
394- # 1. Start the E2E environment (includes Keycloak with pre-configured test users)
424+ # 1. Build images with latest code (if you made changes)
425+ docker build --target backend -t ghcr.io/oriolrius/pki-manager-web/backend:latest -f docker/Dockerfile .
426+ docker build --target frontend -t ghcr.io/oriolrius/pki-manager-web/frontend:latest -f docker/Dockerfile .
427+
428+ # 2. Start the E2E environment (includes Keycloak with pre-configured test users)
395429docker compose -f docker/docker-compose.e2e.yml up -d
396430
397- # 2 . Wait for all services to be healthy (~60-90 seconds for Keycloak)
431+ # 3 . Wait for all services to be healthy (~60-90 seconds for Keycloak)
398432docker compose -f docker/docker-compose.e2e.yml ps
399433
400- # 3 . Run the RBAC tests
434+ # 4 . Run the RBAC tests
401435pnpm playwright test tests/e2e-rbac.spec.ts --reporter=list
402436
403- # 4 . Cleanup when done
437+ # 5 . Cleanup when done
404438docker compose -f docker/docker-compose.e2e.yml down -v
405439```
406440
@@ -461,7 +495,7 @@ pnpm playwright test tests/e2e-rbac.spec.ts
461495cd backend && pnpm typecheck
462496```
463497
464- # ##Image Pull Failures
498+ ### Image Pull Failures
465499
466500** Problem** : Cannot pull from ghcr.io
467501
@@ -529,6 +563,40 @@ FRONTEND_EXTERNAL_PORT=8081
529563KMS_EXTERNAL_PORT=9999
530564```
531565
566+ ### E2E Test Failures
567+
568+ ** Problem** : "no such table: audit_log" error
569+
570+ ** Solution** : Database migrations didn't run. The E2E docker-compose automatically runs migrations on startup. If using a custom setup:
571+ ``` bash
572+ docker exec pki-e2e-backend node /app/backend/dist/db/migrate.js
573+ ```
574+
575+ ** Problem** : OIDC token validation fails in Docker
576+
577+ ** Solution** : Ensure ` OIDC_DISCOVERY_BASE_URL ` is set for Docker networking:
578+ ``` yaml
579+ # docker-compose.e2e.yml
580+ environment :
581+ - OIDC_ISSUER=http://localhost:8180/realms/pki-e2e
582+ - OIDC_DISCOVERY_BASE_URL=http://keycloak:8080/realms/pki-e2e
583+ ` ` `
584+
585+ **Problem**: Keycloak healthcheck fails (timeout)
586+
587+ **Solution**: Keycloak 26+ takes ~60-90 seconds to start. The healthcheck has a 90-second start period. Check logs:
588+ ` ` ` bash
589+ docker logs pki-e2e-keycloak
590+ ```
591+
592+ ** Problem** : Tests fail with "Login button not found"
593+
594+ ** Solution** : Wait for all services to be healthy before running tests:
595+ ``` bash
596+ docker compose -f docker/docker-compose.e2e.yml ps
597+ # All services should show "healthy" status
598+ ```
599+
532600### Production Configuration
533601
534602** Security Checklist** :
0 commit comments