Docker Compose (authzen4)
This summarizes the verified BFF-related settings from CRUDService/docker-compose-authzen4.yml for local/dev stacks.
Note: For full environment variable definitions, see ../reference/settings-reference.md#contents and anchors under each section.
Top services used by BFF
- Traefik (reverse proxy)
- image:
traefik:v3.4.3 - ports: 80, 443, 8080 (dashboard)
- volumes:
./traefik/traefik.yml,./traefik/dynamic.yml - labels: dashboard router protected by
bff-forwardauth@file
- image:
- shared_redis (session store)
- image:
redis:7-alpine - healthcheck:
redis-cli ping
- image:
- bff (Backend for Frontend)
- build:
ms_bff_spike/ms_bff/Dockerfile(targetruntime) - ports:
8000:8000 - env_file:
../ms_bff_spike/.env - volumes:
../ServiceConfigs/BFF/config:/app/config:ro,bff-keys:/app/keys - depends_on:
shared_redis,idp,kafka
- build:
Traefik routers (labels on bff)
- Primary API router (api host)
- rule:
Host(\api.ocg.labs.empowernow.ai`) && (PathPrefix(`/auth/`) || PathPrefix(`/api/`))` - service:
api→ port 8000
- rule:
- SPA hosts (automate, authz, authn)
- Streaming routers (priority 100): intercept
/events/,/stream/, etc. - OAuth/API routers with security headers & rate limit (priority ~90–95)
- Public auth router:
/auth/login,/auth/callback,/auth/forward,/auth/logout,/health
- Streaming routers (priority 100): intercept
ForwardAuth in Compose
- Traefik dashboard:
traefik.http.routers.traefik-dashboard.middlewares=bff-forwardauth@file - Dynamic file must define
bff-forwardauthpointing to BFF/auth/forwardor/auth/verify.
BFF environment (selected)
- Core — see
../reference/settings-reference.md#core-runtimeand anchors#env-ENVIRONMENT,#env-HOST,#env-PORTENVIRONMENT=developmentHOST=0.0.0.0,PORT=8000REDIS_URL=redis://shared_redis:6379/5
- OAuth/IdP — see
../reference/settings-reference.md#authentication-and-oauthidpOIDC_ISSUER=http://idp-app:8002/api/oidcIDP_PUBLIC_BASE=https://idp.ocg.labs.empowernow.ai/api/oidcAUTH_CLIENT_ID,AUTH_CLIENT_SECRET(secrets)MS_BFF_PAR_ENABLED=true,MS_BFF_DPOP_ENABLED=true
- Cookie/Session — see
../reference/settings-reference.md#session-and-cookiesBFF_COOKIE_DOMAIN=.ocg.labs.empowernow.aiSESSION_LIFETIME=3600
- Callback mode — see
../reference/settings-reference.md#callback-url-modelBFF_DYNAMIC_CALLBACK=trueBFF_CALLBACK_URL=https://api.ocg.labs.empowernow.ai/auth/callbackBFF_DEFAULT_HOST=api.ocg.labs.empowernow.ai,BFF_DEFAULT_SCHEME=https
- Security & CORS — see
../reference/settings-reference.md#corsBFF_ALLOWED_REDIRECT_HOSTS=automate...,authn...,authz...,localhost,127.0.0.1CORS__ALLOW_ORIGINS='["https://authn...","https://authz...","https://automate..."]'CSRF_SECRET_KEY(secret)
- Headers & keys
BFF_JWT_SIGNING_KEY=/app/keys/bff-sig-001.pem(mounted volume)
Other services commonly present
idp(../IdP),crud-service(../CRUDService),pdp(../pdp),membership,analytics, Kafka, ClickHouse, Prometheus/Grafana/Jaeger, etc. Traefik routes are defined by labels per service.
Request flow (compose stack)
Bring-up checklist
- Ensure
./traefik/dynamic.ymldefinesbff-forwardauthmiddleware targeting BFF/auth/forwardor/auth/verify - Set secrets (client secrets, salts, keys) via Docker secrets/volumes; do not embed plaintext
- Confirm health endpoints:
GET https://api.ocg.../auth/health - Verify session flow: SPAs call same-origin
/api/**, unauthenticated 401 JSON, then/auth/login