-
Notifications
You must be signed in to change notification settings - Fork 0
Add REQUIRE_AUTH_FOR_SEARCH setting to enforce authentication before searches #101
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
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>
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.
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>
|
@copilot update description for this PR. |
Updated the PR description with the current implementation details, testing results, and technical notes. |
runleveldev
left a comment
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.
Looks good, assuming it's been manually tested we can merge to dev.


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.