feat(audit): record permission denials centrally in the auth middleware - #413
Open
clau1902 wants to merge 10 commits into
Open
feat(audit): record permission denials centrally in the auth middleware#413clau1902 wants to merge 10 commits into
clau1902 wants to merge 10 commits into
Conversation
dviejokfs
force-pushed
the
feat/audit-permission-denied
branch
from
August 6, 2026 14:42
ba3aad4 to
9437e89
Compare
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 7, 2026 12:28
9437e89 to
5258a22
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
Records
PERMISSION_DENIEDcentrally inAuthMiddlewareso authorization-guard 403 responses leave an audit trail without duplicating audit calls across guard macros. Events capture normalized request and credential metadata, support actors without a user ID, and are exposed through the audit-log UI.This branch is rebased onto the latest
main; the previous migration conflict is resolved.Security and review hardening
Load justification
Permission-denial audit writes occur only for rejected control-plane requests. Allowed traffic adds no audit write. The partial retention index is built with
CREATE INDEX CONCURRENTLYafter application boot (or explicitly viatemps migrate) so existing audit writes remain available.Evidence
Permission-denial metadata is UTF-8 safely bounded
cargo test -p temps-auth denial_user_agent_is_utf8_safely_byte_bounded -- --nocaptureReal PostgreSQL migration/index path is idempotent and creates the partial index
cargo test -p temps-database test_establish_connection_with_migrations -- --nocaptureReal backend wire budgets and compatibility
The PostgreSQL test also creates and reads a
text[]row unchanged. The complete Redis crate run verifies a collection larger than the default cell budget returns disjoint offset/cursor pages; incrementally admits list/zset entries; preflights compact set/hash encodings; usesCOUNT 1for scan encodings; rejects oversized aggregate members inside Redis with size-only metadata; enforces the smaller of page/cell budgets; caps page/offset work; and avoids unusable continuation cursors.Permission-denial recorder aggregation paths
cargo test --lib -p temps-auth permission_denial_recorder::tests -- --nocaptureThese tests inspect User-Agent aggregation through the dedicated audit-column accessor, while serialized audit JSON remains intentionally free of duplicate attacker-controlled origin metadata.
The retained permission-denial migration is intentionally a no-op compatibility identity for early PR builds; both
up()anddown()make no schema change. The real PostgreSQL test applies that identity, runs post-migration index maintenance twice, and verifies the resulting partial index.temps migratenow runs the same maintenance even when no schema migrations are pending, while the server retries transient failures with capped backoff.CLI terminal rendering and command helpers
The table test passes malicious OSC content through the real
createTablepath and proves it is removed while the trusted color callback remains.Audit-log UI wiring and rendered component dispatch
The runtime render test dispatches
PERMISSION_DENIEDthroughAuditLogItemRowand asserts its rendered permission, operation, and Authentication category; the filter test calls the same builder used byAuditLogs.Workspace compile and formatting