You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(server): emit audit events when api_key_lifecycle disables/revokes keys
Pass 50 — scheduled-task audit-emission gap. The `api_key_lifecycle`
backstop loop ran four state-changing queries (expired, inactive-global,
inactive-per-key, grace-revoked) each followed by a `tracing::info!`
that logged a count to stderr. None of the four emitted an audit
event — so security teams investigating "why did my API key stop
working at 03:14 UTC?" had to cross-reference application stderr
against PG and hope nothing rotated.
Convert each query from `.execute()` to `.fetch_all()` with
`RETURNING id, user_id`, then run the rows through a shared
`emit_disable_audits` helper that fires `api_key.disabled` (or
`api_key.revoked` for the grace-period case) for every affected
row with a `disabled_reason` detail field distinguishing the four
sub-reasons (`expired` / `inactive_global` / `inactive_per_key` /
`grace_period_expired`).
The expiry-warning step (section 4) was already audited via
`key.expiry_warning` — only the actual state changes were missing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments