Repository navigation
feat: audit event session attribution - #3422
Conversation
…ents to their session
…vent data-key allowlist Add a bearer-token end-to-end test to the entity-CRUD audit bridge spec: a user logs in via the password grant, creates a role with its own bearer, and the resulting entity event must carry the session id the login row names. This covers the AsyncLocalStorage request-context path from the authorization middleware through to the persisted column. Drop sessionId and revokedSessionId from the event data-key allowlist. No emit site writes either into the data bag anymore; a session id rides the dedicated sessionId column. The sanitize spec now pins that both keys are dropped. Assert the two service stamps that went unchecked: the trust-anchor spec feeds a real session id through its fake request context, and the identity-provider account spec wires an event service plus request context so the unlink event's session attribution is covered.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (37)
📝 WalkthroughWalkthroughSecurity events now support nullable, indexed session attribution. Request, OAuth2, MFA, and audit flows populate session IDs. The events API filters by session ID, and the administration console links events and sessions. ChangesSession-Attributed Security Events
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Request
participant AuthenticationFlow
participant EventService
participant EventsAPI
participant AdminConsole
Request->>AuthenticationFlow: provide sessionId
AuthenticationFlow->>EventService: record security event with sessionId
EventService->>EventsAPI: persist and expose sessionId
AdminConsole->>EventsAPI: filter events by sessionId
EventsAPI-->>AdminConsole: return session-attributed events
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
authup
@authup/client-account-console
@authup/client-admin-console
@authup/client-auth-console
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
What
Adds session attribution to the security event log:
auth_eventsgains asession_idcolumn naming theauth_sessionsrow that performed or is affected by each event, queryable viafilter[sessionId]and surfaced in the admin console.How
EventSessionId1786320000000, both dialects): nullable, indexed, deliberately FK-less. The audit table is append-only and sessions are routinely deleted; a CASCADE would erase audit history and SET NULL would destroy the correlation. NULL means not attributable to a session (pre-migration rows, failed logins, registration, password recovery, the unauthenticated external IdP callback).data.sessionIdand LOGOUT dropsdata.revokedSessionId; the sanitizer allowlist follows. Old rows age out via retention (no backfill).sessionIdjoins the event schema fields/filters allow-lists; the existing EVENT_READ gating applies unchanged (session ids were already reachable viarefIdon session-scoped events, so this uniformizes rather than widens exposure)./sessions/:idgains an events section (gated on EVENT_READ) next to the token inventory;/events/:idlinks the session id.data: nullbecauseproviderId/providerNamewere never in the sanitizer allowlist; both keys are now allowlisted, matching the documented plan-091 behavior.Verification
.agents/architecture.mdSecurity Event Log section updated.Summary by CodeRabbit