Skip to content

fix(audit): attach jti to AuthTokenRevoked event metadata#25

Merged
rrrodzilla merged 1 commit into
mainfrom
fix/audit-revoked-jti
May 28, 2026
Merged

fix(audit): attach jti to AuthTokenRevoked event metadata#25
rrrodzilla merged 1 commit into
mainfrom
fix/audit-revoked-jti

Conversation

@rrrodzilla

Copy link
Copy Markdown
Contributor

Summary

The PASETO and JWT auth middlewares emit AuthTokenRevoked when a revoked token is presented, but only attach source.subject. The JTI of the revoked token — the natural correlation key for SIEM rules, retroactive search ("show every request that presented this token"), and revocation-list audit — was in scope at the emission site but dropped before the event was constructed.

The convenience wrapper logger.log_auth(kind, severity, source) doesn't accept metadata. Switch the two emission sites to build the AuditEvent explicitly with with_source(source).with_metadata(json!({"jti": jti})) and call logger.log(event) directly. No API widening — matches the pattern AuditAccountNotification already uses (accounts/mod.rs:744).

Closes #18.

Out of scope

The issue noted that AuthTokenInvalid has similar enrichment value — when validation fails, kid / iss / sometimes sub are available in the decode error but none ship. That's a more invasive change (the decode-error type isn't currently exposed at the middleware emission point) and is tracked under #16 / future follow-up.

Test plan

  • cargo clippy -p acton-service --all-targets --features full -- -D warnings — clean
  • cargo clippy -p acton-service --all-targets --no-default-features --features "full,crypto-ring" -- -D warnings — clean
  • cargo nextest run -p acton-service --features full — 520/520 pass
  • Verify downstream sees metadata.jti populated on auth.token.revoked events after upgrade.

paseto.rs and jwt.rs both emit AuthTokenRevoked when a revoked token is
presented, but only set source.subject — the JTI of the revoked token,
which is the natural correlation key for SIEM rules, retroactive
search ("show every request that presented this token"), and
revocation-list audit, was in scope at the emission site but dropped
before the event was constructed.

log_auth(kind, severity, source) is the convenience wrapper that
doesn't accept metadata. Switch the two emission sites to build the
AuditEvent explicitly with AuditEvent::new(...).with_source(source)
.with_metadata(json!({"jti": jti})) and call logger.log(event)
directly. No API widening; matches the pattern already used by
AuditAccountNotification.

Closes #18.

AuthTokenInvalid enrichment (kid/iss/sub from the decode error) is a
separate, more invasive change tracked under #16 / future work.
@rrrodzilla rrrodzilla merged commit 337f235 into main May 28, 2026
2 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audit: AuthTokenRevoked drops jti, breaking SIEM correlation on the revoked token

1 participant