Update password change audit events to include principal name#3760
Update password change audit events to include principal name#3760joemahady-comm wants to merge 2 commits intocloudfoundry:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a principalName field to AuditEvent so that password change audit events include the human-readable username in log output alongside the existing UUID-based principal field. It also fixes a pre-existing inconsistency in PasswordChangeFailureEvent where principalId used the username instead of the user ID.
Changes:
- Add
principalNamefield toAuditEventwith a new 9-parameter constructor; the existing 8-parameter constructor delegates withnullfor backwards compatibility - Add a
createAuditRecordoverload inAbstractUaaEventacceptingprincipalName, and updatePasswordChangeEventandPasswordChangeFailureEventto supply the username asprincipalName - Update
LoggingAuditServiceto appendprincipalName=[...]to log messages when non-null, and add corresponding unit/integration test coverage
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
server/.../AuditEvent.java |
Adds principalName field, new 9-param constructor (old delegates with null), getter |
server/.../AbstractUaaEvent.java |
Adds new createAuditRecord overload accepting principalName |
server/.../LoggingAuditService.java |
Appends principalName=[...] to log messages when non-null |
server/.../PasswordChangeEvent.java |
Passes username as principalName to createAuditRecord |
server/.../PasswordChangeFailureEvent.java |
Passes user ID as principalId and username as principalName; aligns null-user path |
server/.../LoggingAuditServiceTest.java |
Adds tests for log format with principalName present, with and without authenticationType |
uaa/.../AuditCheckMockMvcTests.java |
Adds assertions for principalName and updates PasswordChangeFailure principal assertion from username to user ID |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
server/src/test/java/org/cloudfoundry/identity/uaa/audit/LoggingAuditServiceTest.java
Show resolved
Hide resolved
server/src/main/java/org/cloudfoundry/identity/uaa/audit/event/AbstractUaaEvent.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Password change audit events (PasswordChangeSuccess/PasswordChangeFailure) log the user ID in the principal field but security audit teams need the human-readable username for compliance.
This change introduces a new principalName field in AuditEvent that is included in the log output when present, without modifying the existing principal field.
Changes: