-
Notifications
You must be signed in to change notification settings - Fork 13k
fix(ldap): prevent excessive logging when Group BaseDN/Filter not configured #38246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
smirk-dev
wants to merge
6
commits into
RocketChat:develop
from
smirk-dev:fix/ldap-excessive-logging-36705
+40
−38,589
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b9ab047
gitignore updated to include yarn.lock and deno.lock
smirk-dev 622d2f8
chore(deps): update @rocket.chat/ui-contexts to version 25.0.2 in yar…
smirk-dev 67925e7
chore: add .github/copilot-instructions.md to .gitignore
smirk-dev e1064ea
Delete packages/apps-engine/deno-runtime/deno.lock
smirk-dev 1d3c5fb
Delete yarn.lock
smirk-dev 2018cdf
fix(ldap): prevent excessive logging when Group BaseDN/Filter not con…
smirk-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| "@rocket.chat/meteor": patch | ||
| --- | ||
|
|
||
| Fixes LDAP excessive logging issue when Group BaseDN or Group Filter are not configured | ||
|
|
||
| When LDAP role/channel sync is enabled with "Validate membership for each group" strategy, but the | ||
| Group BaseDN or Group Filter settings are not configured, the system was logging an error for every | ||
| user and every LDAP group on every sync interval. This could result in thousands of log entries per | ||
| second, filling up ~1GB of logs per day. | ||
|
|
||
| This fix: | ||
| 1. Adds early validation in `syncUserRoles` and `syncUserChannels` to check if BaseDN and Filter are | ||
| configured before entering the iteration loop | ||
| 2. Adds log throttling to the `isUserInGroup` function as a defense in depth measure | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,9 @@ import { syncUserRoles } from '../syncUserRoles'; | |
| import { copyCustomFieldsLDAP } from './copyCustomFieldsLDAP'; | ||
|
|
||
| export class LDAPEEManager extends LDAPManager { | ||
| // Track if we've already logged the missing config error to prevent log spam | ||
| private static hasLoggedMissingGroupConfig = false; | ||
|
|
||
| public static async sync(): Promise<void> { | ||
| if (settings.get('LDAP_Enable') !== true || settings.get('LDAP_Background_Sync') !== true) { | ||
| return; | ||
|
|
@@ -250,7 +253,11 @@ export class LDAPEEManager extends LDAPManager { | |
| groupName: string, | ||
| ): Promise<boolean> { | ||
| if (!filter || !baseDN) { | ||
| logger.error('Please setup LDAP Group Filter and LDAP Group BaseDN in LDAP Settings.'); | ||
| // Log only once to prevent excessive log spam (can be thousands of calls per sync) | ||
| if (!this.hasLoggedMissingGroupConfig) { | ||
| logger.error('Please setup LDAP Group Filter and LDAP Group BaseDN in LDAP Settings.'); | ||
| this.hasLoggedMissingGroupConfig = true; | ||
| } | ||
| return false; | ||
| } | ||
| const searchOptions: ldapjs.SearchOptions = { | ||
|
|
@@ -300,6 +307,13 @@ export class LDAPEEManager extends LDAPManager { | |
| return; | ||
| } | ||
|
|
||
| if (searchStrategy === 'each_group' && (!syncUserRolesBaseDN || !syncUserRolesFilter)) { | ||
| logger.warn( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Missing group-config warning logs once per user sync, still causing log spam when BaseDN/Filter are unset Prompt for AI agents |
||
| 'LDAP Sync User Roles: "Group BaseDN" and "Group Filter" are required when using "Validate membership for each group" strategy. Skipping role sync.', | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const roles = (await Roles.find( | ||
| {}, | ||
| { | ||
|
|
@@ -395,6 +409,13 @@ export class LDAPEEManager extends LDAPManager { | |
| return; | ||
| } | ||
|
|
||
| if (searchStrategy === 'each_group' && (!syncUserChannelsBaseDN || !syncUserChannelsFilter)) { | ||
| logger.warn( | ||
| 'LDAP Sync User Channels: "Group BaseDN" and "Group Filter" are required when using "Validate membership for each group" strategy. Skipping channel sync.', | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const groupsToRoomsMap = this.parseJson(syncUserChannelsFieldMap); | ||
| if (!groupsToRoomsMap) { | ||
| logger.debug('missing group channel mapping'); | ||
|
|
||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hyphenate “defense-in-depth”.
Minor grammar: compound modifier should be hyphenated.
✏️ Proposed edit
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~15-~15: Use a hyphen to join words.
Context: ...he
isUserInGroupfunction as a defense in depth measure(QB_NEW_EN_HYPHEN)
[grammar] ~15-~15: Use a hyphen to join words.
Context: ...
isUserInGroupfunction as a defense in depth measure(QB_NEW_EN_HYPHEN)
🤖 Prompt for AI Agents