mirror of
https://github.com/gogs/gogs.git
synced 2025-05-25 00:40:40 +00:00
auth/ldap: allow placeholder %s for BindDN (#2526)
This commit is contained in:
parent
e1e76d3f88
commit
6f04ee879c
@ -1099,6 +1099,7 @@ auths.domain = Domain
|
||||
auths.host = Host
|
||||
auths.port = Port
|
||||
auths.bind_dn = Bind DN
|
||||
auths.bind_dn_helper = You can use '%s' as placeholder for username, e.g. DOM\%s
|
||||
auths.bind_password = Bind Password
|
||||
auths.bind_password_helper = Warning: This password is stored in plain text. Do not use a high privileged account.
|
||||
auths.user_base = User Search Base
|
||||
|
2
gogs.go
2
gogs.go
@ -16,7 +16,7 @@ import (
|
||||
"github.com/gogits/gogs/pkg/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.11.32.1115"
|
||||
const APP_VER = "0.11.33.1116"
|
||||
|
||||
func init() {
|
||||
setting.AppVer = APP_VER
|
||||
|
@ -96,13 +96,15 @@ func (ls *Source) sanitizedGroupDN(groupDn string) (string, bool) {
|
||||
|
||||
func (ls *Source) findUserDN(l *ldap.Conn, name string) (string, bool) {
|
||||
log.Trace("Search for LDAP user: %s", name)
|
||||
if ls.BindDN != "" && ls.BindPassword != "" {
|
||||
err := l.Bind(ls.BindDN, ls.BindPassword)
|
||||
if len(ls.BindDN) > 0 && len(ls.BindPassword) > 0 {
|
||||
// Replace placeholders with username
|
||||
bindDN := strings.Replace(ls.BindDN, "%s", name, -1)
|
||||
err := l.Bind(bindDN, ls.BindPassword)
|
||||
if err != nil {
|
||||
log.Trace("LDAP: Failed to bind as BindDN '%s': %v", ls.BindDN, err)
|
||||
log.Trace("LDAP: Failed to bind as BindDN '%s': %v", bindDN, err)
|
||||
return "", false
|
||||
}
|
||||
log.Trace("LDAP: Bound as BindDN: %s", ls.BindDN)
|
||||
log.Trace("LDAP: Bound as BindDN: %s", bindDN)
|
||||
} else {
|
||||
log.Trace("LDAP: Proceeding with anonymous LDAP search")
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
0.11.32.1115
|
||||
0.11.33.1116
|
@ -50,6 +50,7 @@
|
||||
<div class="field">
|
||||
<label for="bind_dn">{{.i18n.Tr "admin.auths.bind_dn"}}</label>
|
||||
<input id="bind_dn" name="bind_dn" value="{{$cfg.BindDN}}" placeholder="e.g. cn=Search,dc=mydomain,dc=com">
|
||||
<p class="help text red">{{.i18n.Tr "admin.auths.bind_dn_helper"}}</p>
|
||||
</div>
|
||||
<input class="fake" type="password">
|
||||
<div class="field">
|
||||
|
@ -56,6 +56,7 @@
|
||||
<div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
|
||||
<label for="bind_dn">{{.i18n.Tr "admin.auths.bind_dn"}}</label>
|
||||
<input id="bind_dn" name="bind_dn" value="{{.bind_dn}}" placeholder="e.g. cn=Search,dc=mydomain,dc=com">
|
||||
<p class="help text blue">{{.i18n.Tr "admin.auths.bind_dn_helper"}}</p>
|
||||
</div>
|
||||
<div class="ldap field {{if not (eq .type 2)}}hide{{end}}">
|
||||
<label for="bind_password">{{.i18n.Tr "admin.auths.bind_password"}}</label>
|
||||
|
Loading…
x
Reference in New Issue
Block a user