feat(audit): record permission denials centrally in the auth middleware - #413
Open
clau1902 wants to merge 7 commits into
Open
feat(audit): record permission denials centrally in the auth middleware#413clau1902 wants to merge 7 commits into
clau1902 wants to merge 7 commits into
Conversation
Mark genuine authorization failures explicitly, aggregate them through a bounded non-blocking recorder, and expose only normalized route and principal metadata. Add backend and console regression coverage.
dviejokfs
force-pushed
the
feat/audit-permission-denied
branch
from
August 6, 2026 14:42
ba3aad4 to
9437e89
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 3 of 3 of the auth-failure auditing series — stacked on #411 and #412; review the last commit only until those merge.
403s from the authorization guards were previously invisible: a low-privilege credential probing admin endpoints left no trace.
PERMISSION_DENIEDis recorded byAuthMiddlewarewhenever a response comes back FORBIDDEN. Observing the response centrally covers every guard macro (permission_guard!,project_scope_guard!,project_access_guard!,project_permission_guard!) and any added later, without threading the audit service into the guard macros. The event captures method, path, IP, user agent, and the denied credential (session,cli_token,api_key:<name>,deployment_token:<name>); the actor is optional because deployment tokens carry no user identity. Also wired into the web console filters, categorization, and descriptions.Load justification
Fires only on rejected requests on the admin API (control plane) — one DB insert per denied request, the same cost class as the existing per-write audit logging. Allowed traffic pays nothing.
Test plan
cargo test --lib -p temps-auth— 270 passed (includesPermissionDeniedAuditserialization/actor tests)cargo check --lib— full workspace, cleantsc --noEmit+ eslint clean on changed files🤖 Generated with Claude Code