Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
0f31566b
Commit
0f31566b
authored
Nov 03, 2016
by
Eric Chiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connector: accept base64 encoded CA and add convience open method
parent
53852d4e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
+24
-4
ldap.go
connector/ldap/ldap.go
+24
-4
No files found.
connector/ldap/ldap.go
View file @
0f31566b
...
...
@@ -61,6 +61,9 @@ type Config struct {
// Path to a trusted root certificate file.
RootCA
string
`json:"rootCA"`
// Base64 encoded PEM data containing root CAs.
RootCAData
[]
byte
`json:"rootCAData"`
// BindDN and BindPW for an application service account. The connector uses these
// credentials to search for users and groups.
BindDN
string
`json:"bindDN"`
...
...
@@ -167,6 +170,20 @@ func escapeFilter(s string) string {
// Open returns an authentication strategy using LDAP.
func
(
c
*
Config
)
Open
()
(
connector
.
Connector
,
error
)
{
conn
,
err
:=
c
.
OpenConnector
()
if
err
!=
nil
{
return
nil
,
err
}
return
connector
.
Connector
(
conn
),
nil
}
// OpenConnector is the same as Open but returns a type with all implemented connector interfaces.
func
(
c
*
Config
)
OpenConnector
()
(
interface
{
connector
.
Connector
connector
.
PasswordConnector
connector
.
GroupsConnector
},
error
)
{
requiredFields
:=
[]
struct
{
name
string
val
string
...
...
@@ -196,10 +213,13 @@ func (c *Config) Open() (connector.Connector, error) {
}
tlsConfig
:=
new
(
tls
.
Config
)
if
c
.
RootCA
!=
""
{
data
,
err
:=
ioutil
.
ReadFile
(
c
.
RootCA
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"ldap: read ca file: %v"
,
err
)
if
c
.
RootCA
!=
""
||
len
(
c
.
RootCAData
)
!=
0
{
data
:=
c
.
RootCAData
if
len
(
data
)
==
0
{
var
err
error
if
data
,
err
=
ioutil
.
ReadFile
(
c
.
RootCA
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"ldap: read ca file: %v"
,
err
)
}
}
rootCAs
:=
x509
.
NewCertPool
()
if
!
rootCAs
.
AppendCertsFromPEM
(
data
)
{
...
...
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