fix(audit): emit AuthPermissionDenied, HttpRequestDenied, AuthPasswordChanged#22
Merged
Merged
Conversation
…dChanged Three audit variants were declared in AuditEventKind and listed in every storage parser but had zero emission sites in the framework. Downstream apps relying on the framework for an audit trail got silent gaps for Cedar policy denials, rate-limit rejections, and password changes. - AuthPermissionDenied: emit on Decision::Deny in both the Cedar HTTP middleware (with full AuditSource) and the Cedar gRPC tower service (with subject + UA + request-id from metadata; gRPC has no peer IP at this layer). - HttpRequestDenied: emit in the rate_limit middleware when check_rate_limit_with_route returns Error::RateLimitExceeded. Other error variants (Redis down, etc.) are not audit-worthy and don't emit. - AuthPasswordChanged: AuditAccountNotification was coarsely emitting AccountUpdated with action="password_changed" metadata. Remap to the dedicated AuthPasswordChanged kind at Notice severity; downstream consumers parsing the kind get a distinct, security-relevant event instead of having to inspect action metadata. Tier 1 of #16. Tier 2 (AuthApiKey*, AuthTokenRefresh) and Tier 3 (AuthLogout, AuthOAuthCallback) need design decisions on how to thread AuditLogger through storage traits and session types, tracked separately. Refs #16
3 tasks
rrrodzilla
added a commit
that referenced
this pull request
May 28, 2026
Reflects the audit-event work that landed in #14, #21, #22 and is queued in #23, #25: - audit/page.md: rewrite the "Auth Events (Automatic)" table to match the new emission set (AuthLoginSuccess at Notice; AuthTokenMissing / AuthTokenInvalid added; AuthTokenRevoked notes jti metadata; AuthPermissionDenied and HttpRequestDenied added); update the syslog and OTLP example severities to Notice; expand the "Event Kinds" reference table; add a migration callout for AuthLoginFailed. - cedar-auth/page.md: add "Audit Integration" section describing automatic AuthPermissionDenied emission on Decision::Deny. - rate-limiting/page.md: add "Audit Integration" section describing automatic HttpRequestDenied emission on RateLimitExceeded. - token-auth/page.md: add "Audit Emission" section covering the four middleware-emitted kinds, the jti correlation field, and the AuthLoginFailed migration. Refs #13 #15 #16 #18 #19
3 tasks
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
Closes Tier 1 of #16. Three
AuditEventKindvariants were declared as public API and listed in every storage parser but had no emission site in the framework. Downstream apps that rely on the framework for an audit trail got silent gaps for Cedar policy denials, rate-limit rejections, and password changes. This PR fills them in at the places where the framework already owns the code and has theAuditLoggerin scope.Changes
AuthPermissionDeniedmiddleware/cedar.rs) — emit onDecision::Denywith a populatedAuditSource(IP from X-Forwarded-For / X-Real-IP, user-agent, subject from JWT claims, request-id). Severity:Warning.middleware/cedar.rs) — emit onDecision::Denywith subject + UA + request-id from gRPC metadata. gRPC has no peer IP at this layer;ipstaysNone. Severity:Warning.HttpRequestDeniedmiddleware/rate_limit.rs— emit whencheck_rate_limit_with_routereturnsError::RateLimitExceeded. Other error variants (Redis down, etc.) are not audit-worthy and don't emit. Severity:Warning.AuthPasswordChangedaccounts/mod.rs—AuditAccountNotificationwas coarsely mappingAccountEvent::PasswordChangedtoAuditEventKind::AccountUpdatedwithaction: "password_changed"metadata. Remapped to the dedicatedAuthPasswordChangedkind atNoticeseverity. Downstream consumers parsing the kind now get a distinct, security-relevant event instead of having to inspect metadata.Breaking change
The
AccountUpdatedevent withaction: "password_changed"no longer fires. Downstream SIEM rules keyed on that combination need to switch toauth.password.changed. Justifies a minor-version bump.Out of scope (tracked under #16)
AuthApiKeyCreated,AuthApiKeyRevoked,AuthTokenRefresh— these live behind storage traits (ApiKeyStorage,RefreshTokenStorage) that don't carry anAuditLogger. Needs a notification-handler pattern likeAuditAccountNotificationfor each, wired through all four backends.AuthLogout,AuthOAuthCallback—AuthSession::logout()is sync and has no path to theAuditLogger; the OAuth callback path isn't owned by the framework. Both need design decisions before implementation.Test plan
cargo clippy -p acton-service --all-targets --features full -- -D warnings— cleancargo clippy -p acton-service --all-targets --no-default-features --features "full,crypto-ring" -- -D warnings— cleancargo nextest run -p acton-service --features full— 520/520 pass