feat: dedicated logging for auth and api calls
This commit is contained in:
@@ -99,6 +99,26 @@ Production: point your webserver at `public/` as document root, `APP_ENV=prod`,
|
||||
|
||||
Sessions are stored via Symfony's filesystem cache by default (`config/packages/cache.yaml`) — fine for one instance. For multiple instances behind a load balancer, switch the `bff.session_cache` pool to `cache.adapter.redis` and add `REDIS_DSN`.
|
||||
|
||||
## Logging
|
||||
|
||||
Two dedicated Monolog channels write to their own rotating files in `var/log`, in every environment:
|
||||
|
||||
| File | Channel | Kept | Records |
|
||||
| --- | --- | --- | --- |
|
||||
| `auth.<env>.log` | `auth` | 30 days | The login/logout/authorization trail |
|
||||
| `api.<env>.log` | `api` | 14 days | One record per `/api/*` call |
|
||||
|
||||
**`auth`** — `auth.login.start` and `auth.login.unknown_app` (login redirect), `auth.callback.state_mismatch` and `auth.callback.failed` (a failed code exchange or token decode, previously an anonymous 500), `auth.login.denied` (missing access role), `auth.login.success`, `auth.logout`, and the per-call rejections from `/auth/verify` and `/auth/me`: `auth.session.unauthenticated`, `auth.session.unknown_app`, `auth.session.expired`, `auth.session.access_denied`. Server-side token refreshes add `auth.session.refreshed`, `auth.session.missing`, `auth.session.refresh_failed` and `auth.token.decode_failed`. Successful `verify`/`me` calls are deliberately *not* logged — they run on every page load and would bury the rest.
|
||||
|
||||
**`api`** — `api.request` for every completed proxy call (`info` below status 400, `warning` from 400 up) with method, path, backend, upstream status and `duration_ms`, plus `api.request.unauthenticated`, `api.request.session_expired`, `api.request.unknown_backend` and `api.request.upstream_unreachable`.
|
||||
|
||||
Both channels are excluded from the `main` handler, so records are never duplicated and — importantly in prod, where `main` is `fingers_crossed` — never buffered away just because the request succeeded.
|
||||
|
||||
Two things to know about the content:
|
||||
|
||||
- **It contains PII.** Records carry `user_id` (Keycloak `sub`), `email`, `preferred_username` and the user's role list. Treat `var/log` accordingly: it is a personal-data store, not just diagnostics.
|
||||
- **It never contains credentials.** Sessions appear only as `sid_hash`, a 12-character SHA-256 prefix of the `sid` — enough to follow one session across both files, useless as a bearer token. Access, refresh and ID tokens, request/response bodies, query strings and forwarded headers are never logged.
|
||||
|
||||
## Appsmith app integration
|
||||
|
||||
### Queries to set up
|
||||
|
||||
Reference in New Issue
Block a user