Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
id
keystore
Commits
041ffb0e
Commit
041ffb0e
authored
Jan 13, 2018
by
ale
Browse files
Bind password can be specified directly in the config file
parent
3560f4b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
backend/ldap.go
View file @
041ffb0e
...
...
@@ -73,6 +73,7 @@ func (c *LDAPQueryConfig) searchRequest(username string, attrs ...string) *ldap.
type
LDAPConfig
struct
{
URI
string
`yaml:"uri"`
BindDN
string
`yaml:"bind_dn"`
BindPw
string
`yaml:"bind_pw"`
BindPwFile
string
`yaml:"bind_pw_file"`
Query
*
LDAPQueryConfig
`yaml:"query"`
}
...
...
@@ -85,8 +86,8 @@ func (c *LDAPConfig) Valid() error {
if
c
.
BindDN
==
""
{
return
errors
.
New
(
"empty bind_dn"
)
}
if
c
.
BindPwFile
==
""
{
return
errors
.
New
(
"
empty
bind_pw_file"
)
if
(
c
.
BindPwFile
==
""
&&
c
.
BindPw
==
""
)
||
(
c
.
BindPwFile
!=
""
&&
c
.
BindPw
!=
""
)
{
return
errors
.
New
(
"
only one of
bind_pw_file
or bind_pw must be set
"
)
}
if
c
.
Query
==
nil
{
return
errors
.
New
(
"missing query configuration"
)
...
...
@@ -106,13 +107,17 @@ func NewLDAPBackend(config *LDAPConfig) (*ldapBackend, error) {
}
// Read the bind password.
bindPw
,
err
:=
ioutil
.
ReadFile
(
config
.
BindPwFile
)
if
err
!=
nil
{
return
nil
,
err
bindPw
:=
config
.
BindPw
if
config
.
BindPwFile
!=
""
{
pwData
,
err
:=
ioutil
.
ReadFile
(
config
.
BindPwFile
)
if
err
!=
nil
{
return
nil
,
err
}
bindPw
=
strings
.
TrimSpace
(
string
(
pwData
))
}
// Connect.
pool
,
err
:=
ldaputil
.
NewConnectionPool
(
config
.
URI
,
config
.
BindDN
,
strings
.
TrimSpace
(
string
(
bindPw
))
,
5
)
pool
,
err
:=
ldaputil
.
NewConnectionPool
(
config
.
URI
,
config
.
BindDN
,
bindPw
,
5
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment