[PR #6723] [management] deduplicate JWT group claims #29839

Open
opened 2026-08-05 08:09:07 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6723
Author: @CoderSufiyan
Created: 7/10/2026
Status: 🔄 Open

Base: mainHead: fix/issue-6618-dedupe-jwt-groups


📝 Commits (1)

  • 65a7013 [management] deduplicate JWT group claims

📊 Changes

2 files changed (+13 additions, -1 deletions)

View changed files

📝 management/server/account.go (+11 -0)
📝 management/server/account_test.go (+2 -1)

📄 Description

Description

JWT group claims can contain repeated names when multiple identity-provider mappings emit the same group. The synchronization path preserved those duplicates, creating multiple JWT groups with the same name and assigning every generated group ID to the user.

This deduplicates claimed group names before calculating membership changes while preserving their original order and case.

Changes

  • Deduplicate JWT group names at the synchronization boundary
  • Extend the existing JWT group sync test with repeated claim values
  • Verify both group records and user memberships remain unique

Testing

  • go test ./management/server -run '^TestDefaultAccountManager_SyncUserJWTGroups$' -count=1
  • go test ./management/server/util -count=1
  • go build ./management/...
  • go vet ./management/server ./management/server/util

Fixes #6618

Summary by CodeRabbit

  • Bug Fixes
    • Prevented duplicate group assignments when incoming group claims contain repeated entries.
    • Group synchronization now produces only unique auto-group memberships.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6723 **Author:** [@CoderSufiyan](https://github.com/CoderSufiyan) **Created:** 7/10/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/issue-6618-dedupe-jwt-groups` --- ### 📝 Commits (1) - [`65a7013`](https://github.com/netbirdio/netbird/commit/65a7013c6d3abdb8dc28b3ec503c59ebfb5579b4) [management] deduplicate JWT group claims ### 📊 Changes **2 files changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `management/server/account.go` (+11 -0) 📝 `management/server/account_test.go` (+2 -1) </details> ### 📄 Description ## Description JWT group claims can contain repeated names when multiple identity-provider mappings emit the same group. The synchronization path preserved those duplicates, creating multiple JWT groups with the same name and assigning every generated group ID to the user. This deduplicates claimed group names before calculating membership changes while preserving their original order and case. ## Changes - Deduplicate JWT group names at the synchronization boundary - Extend the existing JWT group sync test with repeated claim values - Verify both group records and user memberships remain unique ## Testing - `go test ./management/server -run '^TestDefaultAccountManager_SyncUserJWTGroups$' -count=1` - `go test ./management/server/util -count=1` - `go build ./management/...` - `go vet ./management/server ./management/server/util` Fixes #6618 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Prevented duplicate group assignments when incoming group claims contain repeated entries. * Group synchronization now produces only unique auto-group memberships. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:09:07 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#29839