Backend-for-Frontend Service (svc-bff)
Overview
svc-bff is a FastAPI transparent proxy that sits between nginx and svc-core. It validates the user session, retrieves the Auth0 access token from Redis, and forwards it in the Authorization header on every downstream call. It also mints a short-lived, audience-bound internal JWT (X-Internal-Token) so svc-core can verify the caller rather than trusting raw identity headers. It does not aggregate or transform data.
Internal port: 4000 (not exposed to host)
Responsibilities
Validate the signed session cookie on every request
Retrieve the access token for the session from Redis
Forward requests to svc-core with the
Authorization: Bearer <token>header injectedMint a short-lived, audience-bound internal JWT (
X-Internal-Token,aud=svc-core) per request for svc-core to verifyPropagate user identity headers (
X-User-Id,X-User-Email,X-User-Name) to downstream servicesProxy WebSocket connections for real-time (SSE/streaming) endpoints
Handle multipart file uploads (reconstructs
Content-Typeboundary)
API Endpoints
See spec/api/svc-bff.md for the full auto-generated reference.
| Method | Path | Description |
|---|---|---|
GET/POST/PUT/DELETE/PATCH/HEAD/OPTIONS | /proxy/{path} | Transparent proxy to svc-core |
WebSocket | /ws/{path} | WebSocket proxy to svc-core |
GET | /debug/session | Session debug info (dev mode only) |
nginx maps /api/* → svc-bff /proxy/* and /api/ws/* → svc-bff /ws/*.
Request Flow
nginx (auth verified)
↓ Cookie: sid=<signed_session_id>
svc-bff /proxy/{path}
↓ decode cookie → session_id
↓ Redis GET session:{session_id} → access_token
↓ mint short-lived internal JWT (aud=svc-core, sub=user_id)
↓ forward request to svc-core with:
Authorization: Bearer <access_token>
X-Internal-Token: <signed internal JWT> # verified by svc-core
X-User-Id: <user_id>
X-User-Email: <email>
X-User-Name: <name>
svc-core
If the session cookie is missing, invalid, or the token cannot be found in Redis, svc-bff returns 401.
Configuration
| Variable | Description | Default |
|---|---|---|
REDIS_URL | Redis connection URL | redis://redis:6379 |
REDIS_PASSWORD | Redis password | optional |
SESSION_COOKIE_NAME | Cookie name (must match svc-auth) | sid |
SESSION_SECRET | Cookie signing secret (must match svc-auth) | required |
PROXY_TIMEOUT | Downstream request timeout in seconds | 60 |
ENVIRONMENT | development / production | development |
INTERNAL_JWT_SECRET | Shared secret for minting internal service JWTs (required outside local/dev; ≥32 chars) | — |
INTERNAL_JWT_ISSUER | iss claim for minted tokens | svc-bff |
INTERNAL_JWT_AUDIENCE | aud claim for minted tokens (svc-core verifies) | svc-core |
INTERNAL_JWT_TTL | Token lifetime in seconds | 120 |
Runtime Dependencies
Redis — reads access tokens stored by svc-auth (
bff-network)svc-core — proxies all API traffic (
backend-network)
No dedicated PostgreSQL database.
Networks
bff-network— Redis accessbackend-network— svc-core access