Repository navigation
Conversation
- added `ENTRA_ID_SYNC_ONLY_EXISTING_GROUPS` to skip creating missing groups during login sync
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The toggle lacks required YAML configuration support, and new backend behavior was added to the legacy CJS layer.
Review effort: Balanced
Findings: 3
Open (3)
What changed in this PR
Adds an opt-in mode that limits login-time Entra synchronization to groups already stored locally, reducing ACL principal growth.
Changes:
- Skips missing-group creation when the flag is enabled.
- Documents the new environment variable.
- Tests membership additions, removals, and skipped creation.
| File | Description |
|---|---|
.env.example |
Documents the new toggle. |
api/server/services/PermissionService.js |
Applies existing-group-only synchronization. |
api/server/services/PermissionService.spec.js |
Tests enabled and default behavior. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- added `permissions.syncOnlyExistingEntraGroups` to `librechat.yaml` and moved the setting resolution into `packages/api`
jtodaroii
marked this pull request as ready for review
October 1, 2026 20:38
1 task done
1 task done
Contributor
Author
|
@danny-avila Merged current |
…-existing-groups # Conflicts: # librechat.example.yaml # packages/data-provider/src/config.ts
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Login-time Entra sync creates a
Groupfor every Entra group the user belongs to, so in large tenants thousands of groups that are never shared with end up in every user's ACL principal list. This adds an opt-in setting,permissions.syncOnlyExistingEntraGroupsinlibrechat.yaml(env fallbackENTRA_ID_SYNC_ONLY_EXISTING_GROUPS), that skips creating missing groups during sync. Membership is still added and removed on groups already in the database, which are created when someone shares a resource with them. Default behavior is unchanged.Closes #16633
Related to #15830, #16233
How it works
syncsOnlyExistingEntraGroupsinpackages/api/src/acl/principals.tsresolves the setting: thelibrechat.yamlvalue wins when set, otherwise the env flag decides. The OAuth callback runs before the config middleware, sooauth.jsresolves the user's app config and passes it tosyncUserEntraGroupMemberships, which skips steps 4–6 (fetch details, upsert, add) when the setting is on.Type of change
Testing
Tested environments/configuration:
mongodb-memory-serverlibrechat.yamltrue/false/unset, env flag true/unsetAutomated tests:
api/server/services/PermissionService.spec.js: missing groups are not fetched or created with the env flag or the YAML setting; the user is still removed from existing groups they left; the YAML setting overrides the env flag. Each new case fails without the change.packages/api/src/acl/principals.spec.ts: precedence of the YAML setting over the env flag.PermissionService.spec.jsplus theoauth,oauth.stateandadmin/auth.refreshroute suites: 135 passed;principals.spec.ts: 7 passed.Screenshots / recordings
No user-facing change
Risk / compatibility