Skip to content
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

Add %p wildcard for Bind Password in LDAP BindDN to allow for self-binding to LDAP #6565

Open
cstepaniak opened this issue May 21, 2021 · 0 comments · May be fixed by #6566
Open

Add %p wildcard for Bind Password in LDAP BindDN to allow for self-binding to LDAP #6565

cstepaniak opened this issue May 21, 2021 · 0 comments · May be fixed by #6566

Comments

@cstepaniak
Copy link

cstepaniak commented May 21, 2021

Describe the feature
Add the ability to bind to LDAP with user's credentials, for situations where neither anonymous bind allowed nor a dedicated LDAP bind user is available.

Describe the solution you'd like
Add the %p wildcard to "Bind Password" in LDAP BindDN (similar to %s for the username) to pass the user-entered password to bind to LDAP.

Describe alternatives you've considered
I've not been able to get Gogs to connect to LDAP for our AD domain. The admins won't allow anonymous bind nor create a dedicated bind user, so I patched Gogs to pass through the user's password for use in binding to LDAP

Additional context
diff of internal/auth/ldap/config.go below:

111c111
< func (c *Config) findUserDN(l *ldap.Conn, name string) (string, bool) {
---
> func (c *Config) findUserDN(l *ldap.Conn, name string, passwd string) (string, bool) {
116c116,119
<               err := l.Bind(bindDN, c.BindPassword)
---
>               bindPW := strings.Replace(c.BindPassword, "%p", passwd, -1)
>               err := l.Bind(bindDN, bindPW)
220c223
<               userDN, found = c.findUserDN(l, name)
---
>               userDN, found = c.findUserDN(l, name, passwd)
@cstepaniak cstepaniak linked a pull request May 24, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant