Skip to content

Add explicit group membership audit events - #4132

Open
duanemay wants to merge 4 commits into
developfrom
feature/group-membership-audit-events
Open

duanemay wants to merge 4 commits into
developfrom
feature/group-membership-audit-events

Conversation

@duanemay

@duanemay duanemay commented Nov 4, 2026

Copy link
Copy Markdown
Member

Make group membership auditing consistent across these three API operations:

  • Whole-group updates, PUT /Groups/{groupId}: previously emitted only GroupModifiedEvent, listing the members after the update without identifying who was added or removed. Now emit GroupMembershipAddedEvent and GroupMembershipRemovedEvent as needed for the affected members, followed by GroupModifiedEvent. Whole-group PATCH /Groups/{groupId} now follows the same behavior.
  • Single-member additions, POST /Groups/{groupId}/members: previously emitted no group audit events. Now emit GroupMembershipAddedEvent, followed by GroupModifiedEvent.
  • Single-member removals, DELETE /Groups/{groupId}/members/{memberId}: previously emitted no group audit events. Now emit GroupMembershipRemovedEvent, followed by GroupModifiedEvent.

The new membership events identify the affected member by ID, name and type. The existing GroupModifiedEvent payload stays unchanged and contains the complete resulting membership list.

Adding a member

GroupMembershipAddedEvent ('{"group_name":"uaa.admin","member_id":"fcaf388e-a219-4a2e-8602-764c7fa3b210","member_name":"marissa","member_type":"USER"}'): principal=5290a3ae-4a93-4599-a2ed-06fec53c09ce, origin=[...], identityZoneId=[uaa]

Removing a member

GroupMembershipRemovedEvent ('{"group_name":"uaa.admin","member_id":"fcaf388e-a219-4a2e-8602-764c7fa3b210","member_name":"marissa","member_type":"USER"}'): principal=5290a3ae-4a93-4599-a2ed-06fec53c09ce, origin=[...], identityZoneId=[uaa]

Copilot AI balanced review requested due to automatic review settings November 4, 2026 23:11
@github-actions github-actions Bot added the size/l label Nov 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A concurrency race can leave successful membership changes unaudited because prepared events may become stale before the actual mutations occur.

1 open issue
What changed in this PR

Adds explicit membership audit events to UAA’s SCIM group APIs while preserving the existing GroupModifiedEvent payload.

Changes:

  • Adds membership-added and membership-removed events identifying the affected member.
  • Publishes membership events before the final group snapshot for whole-group PUT/PATCH and single-member POST/DELETE operations.
  • Adds tests for event ordering, payloads, identity zones, and failed requests.
File Description
uaa/​src/​test/​java/​org/​cloudfoundry/​identity/​uaa/​scim/​endpoints/​ScimGroupEndpointsTests.java Updates endpoint construction for publisher injection.
uaa/​src/​test/​java/​org/​cloudfoundry/​identity/​uaa/​mock/​audit/​AuditCheckMockMvcTests.java Adds end-to-end membership audit coverage.
server/​src/​test/​java/​org/​cloudfoundry/​identity/​uaa/​scim/​event/​ScimMembershipEventPublisherTests.java Tests change detection, name lookup, and fallback behavior.
server/​src/​main/​java/​org/​cloudfoundry/​identity/​uaa/​scim/​event/​ScimEventPublisher.java Prepares, enriches, and publishes membership events.
server/​src/​main/​java/​org/​cloudfoundry/​identity/​uaa/​scim/​event/​GroupMembershipEvent.java Defines the membership audit payload.
server/​src/​main/​java/​org/​cloudfoundry/​identity/​uaa/​scim/​endpoints/​ScimGroupEndpoints.java Integrates auditing into membership operations.
server/​src/​main/​java/​org/​cloudfoundry/​identity/​uaa/​scim/​beans/​ScimBeanConfiguration.java Injects provisioning services for member-name lookup.
server/​src/​main/​java/​org/​cloudfoundry/​identity/​uaa/​scim/​beans/​ScimAopConfig.java Extends group-modified auditing to PATCH.
server/​src/​main/​java/​org/​cloudfoundry/​identity/​uaa/​audit/​AuditEventType.java Adds two membership audit event codes.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A critical data-integrity issue remains because long group or member names can be truncated into invalid JSON audit records, and a test-convention nit also remains unresolved.

2 open issues
1 resolved since last review

Review effort: Lite

strehle
strehle previously approved these changes Nov 5, 2026
@github-project-automation github-project-automation Bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Nov 5, 2026
Emit named membership-added and membership-removed events for group updates
and single-member operations. Preserve the existing group-modified event
payload and publish it last for both group updates and single-member changes.
Exercise overlapping whole-group and single-member changes with
latch-controlled requests. Require success events to wait for commit and
failed updates to preserve membership and metadata.

These regression tests intentionally fail before transaction coordination
is applied.
Coordinate whole-group PUT/PATCH and single-member POST/DELETE with a
zone-scoped group lock held in a database transaction. Publish membership
audit events after commit and roll back partial updates on failure.

Add contract checks for the new locking helper and update endpoint test
construction for its dependency.
Replace timed latch and future waits with Awaitility conditions while
retaining request sequencing and continuous blocked-state assertions.
Preserve worker failure propagation after completion.
@duanemay
duanemay force-pushed the feature/group-membership-audit-events branch from 6d7fdb8 to a07cca5 Compare November 6, 2026 19:17
@fhanik
fhanik self-requested a review November 10, 2026 01:17

This branch has not been deployed

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

Labels

Projects

Status: Pending Merge | Prioritized

Development

Successfully merging this pull request may close these issues.

4 participants