Skip to content

Update password change audit events to include principal name#3760

Open
joemahady-comm wants to merge 2 commits intocloudfoundry:developfrom
joemahady-comm:TNZ-84736
Open

Update password change audit events to include principal name#3760
joemahady-comm wants to merge 2 commits intocloudfoundry:developfrom
joemahady-comm:TNZ-84736

Conversation

@joemahady-comm
Copy link
Contributor

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:

  • Add principalName field to AuditEvent with a new constructor overload (existing constructor delegates with null for backwards compatibility)
  • Add createAuditRecord overload in AbstractUaaEvent that accepts principalName
  • Update LoggingAuditService to append principalName=[...] to log messages when set
  • Update PasswordChangeEvent to populate principalName with the username
  • Update PasswordChangeFailureEvent to populate principalName with the username, and align principalId to use user ID (was previously username) for consistency with success events

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 principalName field to AuditEvent with a new 9-parameter constructor; the existing 8-parameter constructor delegates with null for backwards compatibility
  • Add a createAuditRecord overload in AbstractUaaEvent accepting principalName, and update PasswordChangeEvent and PasswordChangeFailureEvent to supply the username as principalName
  • Update LoggingAuditService to append principalName=[...] 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants