Skip to content

Azure: match groups/baseGroups by object ID as well as display name - #428

Open
jirolin wants to merge 1 commit into
redhat-cop:mainfrom
jirolin:fix/azure-match-groups-by-object-id
Open

jirolin wants to merge 1 commit into
redhat-cop:mainfrom
jirolin:fix/azure-match-groups-by-object-id

Conversation

@jirolin

@jirolin jirolin commented Jul 18, 2026

Copy link
Copy Markdown

Problem

The Azure provider's groups and baseGroups filters only match against a group's display name:

  • baseGroups builds the Graph query displayName eq '<value>'
  • groups filters enumerated groups client-side via isGroupAllowed(displayName, ...)

Azure AD group display names are mutable and not unique, so operators frequently configure the stable, unique object ID (GUID) instead. When an object ID is supplied today nothing matches and Sync() returns 0 groups, with no error and no warning — the reconcile reports success and, with prune: false, any pre-existing group objects are left in place looking "synced", so the misconfiguration is effectively invisible.

Change

  • groups now matches an enumerated group by its display name OR object ID.
  • baseGroups resolves each entry via id eq '<guid>' when it is a valid GUID and displayName eq '<name>' otherwise. The two forms cannot be merged into a single displayName eq '…' or id eq '…' filter, because id eq '<non-guid>' is rejected by Microsoft Graph with Request_BadRequest.
  • A warning is logged when a non-empty groups filter matches nothing, so the misconfiguration is visible instead of silently succeeding.

All changes are backward compatible — existing display-name configuration keeps working unchanged.

Testing

  • go build ./..., go vet ./pkg/syncer/
  • go test ./pkg/syncer/ (existing suite + new tests pass)
  • New unit tests: TestAzureBaseGroupFilter, TestAzureGroupMatches

🤖 Generated with Claude Code

The Azure provider's `groups` and `baseGroups` filters previously only
matched a group's display name. Azure AD display names are mutable and
not unique, so operators commonly configure the stable object ID (GUID)
instead. In that case the sync silently matched nothing and completed
with zero groups and no diagnostic.

- `groups` now matches an enumerated group by display name OR object ID
- `baseGroups` resolves an entry via "id eq" when it is a GUID and
  "displayName eq" otherwise (the two cannot be combined because
  "id eq '<non-guid>'" is rejected by Microsoft Graph / Request_BadRequest)
- a warning is logged when a non-empty `groups` filter matches nothing,
  so misconfiguration is visible instead of silently succeeding

Adds unit tests for azureBaseGroupFilter and azureGroupMatches.

Signed-off-by: lw12003 <jiro.higuchi@shi-g.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sabre1041

Copy link
Copy Markdown
Collaborator

Hi @jirolin . There have been a number of changes to the operator recently. Would you be able to rebase/resolve the merge conflicts and we'll get to reviewing the PR?

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants