fix(security): internal authorize hop + structured logging - #366
Conversation
…uctured logging Task 1: completeOidcWithSession's authorize fetch hairpinned out through Cloudflare/ingress to the EXTERNAL authorize URL (~6.5s per prod timing logs) instead of the internal Authentik service DNS oidc.ts already uses for token/userinfo/jwks. toInternalAuthorizeUrl() rewrites protocol+host only (redirect_uri/state/PKCE unchanged) so token validation is unaffected. Expected ~6.5s -> ~0.2s on that hop. Task 2: add a shared pino logger (src/lib/logger.ts) with LOG_LEVEL control and mandatory credential/token/cookie redaction, and instrument the previously-silent auth-critical paths (authentikPassword, oidc, googleOidc, brokerCodes, api-token, organizationProvisioning, authz.ts) with boundary start/end + elapsed-ms + decision-branch + error-context logging. Converts PR #362's temporary console.log timing lines to leveled logger calls. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session-Id: f636c22e-1cd7-401e-8843-97e3e3a4ba01
pino@^9.5.0 was added to backend/security/package.json but the root package-lock.json was not updated, causing npm ci to fail with a lock-file/package.json mismatch. Ran npm install --package-lock-only to resolve pino@9.14.0 into backend/node_modules/pino and record it in the workspace dependencies section. Fixes failing CI on PR #366. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CI Fix:
|
CI fix — gate-frontend-build lock-file mismatchRoot cause: This PR added Fix (already on branch): I've regenerated
The existing To apply: Merge or cherry-pick from |
CI Fix — branch pushed, PR creation blockedRoot cause: PR #366 added This cascaded: Fix: Ran Fix branch: A PR from that branch → |
Summary
completeOidcWithSession(authentikPassword.ts) now rewrites the brokered OIDC authorize URL onto the internalAUTHENTIK_BASE_URL(protocol+host only; redirect_uri/state/PKCE unchanged) instead of hairpinning out through Cloudflare/ingress. Prod timing showed this hop alone at ~6.5s; expected ~0.2s after the fix. Remaining ~5.4s (Authentik's internal flow executor, 6 hops) is out of scope — flagged for follow-up.backend/security/src/lib/logger.ts) —LOG_LEVEL-controlled (default info, debug for per-hop detail without redeploy), JSON/ISO timestamps, mandatory redaction of password/token/code/cookie/authorization-shaped fields. Instruments the previously-silent auth-critical files (authentikPassword.ts,oidc.ts,googleOidc.ts,brokerCodes.ts,api-token.ts,organizationProvisioning.ts,routes/authz.ts) with boundary start/end + elapsed-ms + decision-branch + error-context logging, and converts PR fix(security): hard per-fetch timeout + per-step timing on password login #362's temporaryconsole.logtiming lines to leveled logger calls.Test plan
tsc --noEmitagainst edited files (local workspace npm install hit the documented Windows npm-cache ENOTEMPTY corruption; verified with a clean isolated typescript install instead)Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com