feat: try anonymous bind when bind credentials are empty - #979
Conversation
When BindDN and bindPw are empty, attempt unauthenticated bind (normal bind crashes with code 206). This allows connecting to LDAP servers that support anonymous access without requiring authentication.
📝 WalkthroughWalkthroughThe BindService function in the LDAP service now checks whether both BindDN and the derived bind password are empty. When true, it performs an unauthenticated LDAP bind instead of the standard authenticated bind, leaving the existing mTLS/external-bind path unchanged. ChangesLDAP Bind Flow
Estimated code review effort: 2 (Simple) | ~10 minutes Related PRs: None identified from the provided context. Suggested labels: ldap, bug-fix Suggested reviewers: None identified from the provided context. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/service/ldap_service.go`:
- Around line 249-255: The anonymous bind branch in ldap_service.go can hide a
bind password file read failure because ldap.bindPw may be empty when
utils.GetSecret fails, causing UnauthenticatedBind("") to run silently. Update
the LDAP bind setup around ldap.config.LDAP.BindDN, ldap.bindPw, and
utils.GetSecret so a BindPasswordFile read error is surfaced as a warning or
returned error before falling back to anonymous bind. Keep the
UnauthenticatedBind("") path only for the intentional case where both BindDN and
bind password are truly unset.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 07907a9b-79b6-4792-b130-827585792f97
📒 Files selected for processing (1)
internal/service/ldap_service.go
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Thanks @nv6! |
Allow anonymous bind (i.e. unauthenticated) when the bind username and password aren't provided, to support LDAP servers which allow anonymous access, e.g. for directory lookups. This avoids a fatal error which currently occurs when attempting an anonymous bind:
Summary by CodeRabbit