Add REQUIRE_AUTH_FOR_SEARCH setting to enforce authentication before searches#101
Merged
anishapant21 merged 7 commits intodevfrom Dec 3, 2025
Merged
Conversation
Co-authored-by: anishapant21 <44058515+anishapant21@users.noreply.github.com>
Track authenticated connections manually to determine if search should be allowed. This works around ldapjs not updating bindDN properly with async bind handlers. Co-authored-by: anishapant21 <44058515+anishapant21@users.noreply.github.com>
Co-authored-by: anishapant21 <44058515+anishapant21@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add authentication requirement for LDAP search in production
Add REQUIRE_AUTH_FOR_SEARCH setting to enforce authentication before searches
Nov 18, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a REQUIRE_AUTH_FOR_SEARCH configuration option to enforce authentication before allowing LDAP search operations, addressing security requirements for production deployments.
Key changes:
- Adds authentication tracking using a Set to track connection IDs that have successfully authenticated
- Implements authorization middleware in the search handler that rejects unauthenticated requests with LDAP error 50 when enabled
- Provides backward compatibility by defaulting to
false, allowing anonymous searches in development environments
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
server/config/configurationLoader.js |
Adds boolean configuration parsing for REQUIRE_AUTH_FOR_SEARCH environment variable |
server/serverMain.js |
Passes the requireAuthForSearch config option to LdapEngine constructor |
server/.env.example |
Documents the new setting with clear guidance for production vs development usage |
npm/src/LdapEngine.js |
Implements core authentication tracking and authorization middleware for search operations |
README.md |
Adds comprehensive documentation with examples showing the security benefits and usage patterns |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Collaborator
Collaborator
|
@copilot update description for this PR. |
Contributor
Author
Updated the PR description with the current implementation details, testing results, and technical notes. |
runleveldev
approved these changes
Dec 2, 2025
Contributor
runleveldev
left a comment
There was a problem hiding this comment.
Looks good, assuming it's been manually tested we can merge to dev.
anishapant21
approved these changes
Dec 3, 2025
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.


Production LDAP servers should not allow anonymous directory enumeration. This adds a configuration option to require authentication before permitting search operations.
Changes
Configuration
REQUIRE_AUTH_FOR_SEARCHenvironment variable (default:truefor security)true, returns LDAP error 50 (Insufficient Access Rights) for unauthenticated searchesImplementation (
npm/src/LdapEngine.js)req.connection.ldap.bindDNto check authentication statusDocumentation
.env.exampleandREADME.mdwith security recommendationsExample
Technical Note
Uses ldapjs native
req.connection.ldap.bindDNproperty to determine authentication status. When a client performs an anonymous bind, ldapjs sets this tocn=anonymous. The authorization middleware checks for this value to determine if the connection is authenticated.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.