v3.5.2 7 February 2026 Fix
Auth Audit Log Fix
Fixed
- Auth audit logging restored — Login, logout, TOTP verification, password change, password reset, and email verification events are now recorded again after RLS broke the audit trail on auth routes (
bug_azq6)
Root Cause
The fastify.audit.log() helper writes to the tenant-scoped audit_log table via the connection pool. After RLS was enabled in v3.5.0, INSERT operations on auth routes failed silently because no app.current_org_id session variable is set outside the tenant middleware. Auth events were lost — no user-facing impact, but security events went unrecorded.
Resolution
- New
auth_audit_logtable — Global table outside RLS scope, purpose-built for security events that occur before tenant context exists. Capturesevent_type,user_id,email,ip_address,user_agent, anddetails(JSONB) - New
fastify.authAudit.log()decorator — Writes directly toauth_audit_logvia the pool, mirroring the existingfastify.audit.log()pattern - Auth routes migrated — All 12 audit calls across
auth.ts,password-reset.ts, andemail-verification.tsnow useauthAudit.log()instead ofaudit.log() - Tenant-scoped
audit_logtable unchanged — business event audit trail remains RLS-protected
Files Changed
db/migrations/v3.5.2-auth-audit-log.sql— Migration: table, indexes, grantssrc/server.ts—AuthAuditEntryinterface,authAuditdecoratorsrc/routes/auth.ts— 8 audit calls migratedsrc/routes/password-reset.ts— 2 audit calls migratedsrc/routes/email-verification.ts— 2 audit calls migrated
Housekeeping
- Removed stale
organisation.ts.bakfile