Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
74eaec60
Commit
74eaec60
authored
8 years ago
by
Eric Chiang
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #661 from rithujohn191/gRPC-client-auth
cmd/dex: add option for gRPC client auth CA.
parents
799b3f3e
42dfd3ec
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Documentation/api.md
+2
-0
2 additions, 0 deletions
Documentation/api.md
cmd/dex/config.go
+4
-3
4 additions, 3 deletions
cmd/dex/config.go
cmd/dex/serve.go
+32
-4
32 additions, 4 deletions
cmd/dex/serve.go
examples/config-dev.yaml
+1
-0
1 addition, 0 deletions
examples/config-dev.yaml
with
39 additions
and
7 deletions
Documentation/api.md
+
2
−
0
View file @
74eaec60
...
...
@@ -15,6 +15,8 @@ grpc:
# Server certs. If TLS credentials aren't provided dex will generate self-signed ones.
tlsCert: /etc/dex/grpc.crt
tlsKey: /etc/dex/grpc.key
# Client auth CA.
tlsClientCA: /etc/dex/client.crt
```
## Generating clients
...
...
This diff is collapsed.
Click to expand it.
cmd/dex/config.go
+
4
−
3
View file @
74eaec60
...
...
@@ -88,9 +88,10 @@ type Web struct {
// GRPC is the config for the gRPC API.
type
GRPC
struct
{
// The port to listen on.
Addr
string
`yaml:"addr"`
TLSCert
string
`yaml:"tlsCert"`
TLSKey
string
`yaml:"tlsKey"`
Addr
string
`yaml:"addr"`
TLSCert
string
`yaml:"tlsCert"`
TLSKey
string
`yaml:"tlsKey"`
TLSClientCA
string
`yaml:"tlsClientCA"`
}
// Storage holds app's storage configuration.
...
...
This diff is collapsed.
Click to expand it.
cmd/dex/serve.go
+
32
−
4
View file @
74eaec60
package
main
import
(
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
...
...
@@ -67,6 +69,7 @@ func serve(cmd *cobra.Command, args []string) error {
{
c
.
GRPC
.
TLSCert
!=
""
&&
c
.
GRPC
.
Addr
==
""
,
"no address specified for gRPC"
},
{
c
.
GRPC
.
TLSKey
!=
""
&&
c
.
GRPC
.
Addr
==
""
,
"no address specified for gRPC"
},
{(
c
.
GRPC
.
TLSCert
==
""
)
!=
(
c
.
GRPC
.
TLSKey
==
""
),
"must specific both a gRPC TLS cert and key"
},
{
c
.
GRPC
.
TLSCert
==
""
&&
c
.
GRPC
.
TLSClientCA
!=
""
,
"cannot specify gRPC TLS client CA without a gRPC TLS cert"
},
}
for
_
,
check
:=
range
checks
{
...
...
@@ -77,11 +80,36 @@ func serve(cmd *cobra.Command, args []string) error {
var
grpcOptions
[]
grpc
.
ServerOption
if
c
.
GRPC
.
TLSCert
!=
""
{
opt
,
err
:=
credentials
.
NewServerTLSFromFile
(
c
.
GRPC
.
TLSCert
,
c
.
GRPC
.
TLSKey
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"load grpc certs: %v"
,
err
)
if
c
.
GRPC
.
TLSClientCA
!=
""
{
// Parse certificates from certificate file and key file for server.
cert
,
err
:=
tls
.
LoadX509KeyPair
(
c
.
GRPC
.
TLSCert
,
c
.
GRPC
.
TLSKey
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"parsing certificate file: %v"
,
err
)
}
// Parse certificates from client CA file to a new CertPool.
cPool
:=
x509
.
NewCertPool
()
clientCert
,
err
:=
ioutil
.
ReadFile
(
c
.
GRPC
.
TLSClientCA
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"reading from client CA file: %v"
,
err
)
}
if
cPool
.
AppendCertsFromPEM
(
clientCert
)
!=
true
{
return
errors
.
New
(
"failed to parse client CA"
)
}
tlsConfig
:=
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
cert
},
ClientAuth
:
tls
.
RequireAndVerifyClientCert
,
ClientCAs
:
cPool
,
}
grpcOptions
=
append
(
grpcOptions
,
grpc
.
Creds
(
credentials
.
NewTLS
(
&
tlsConfig
)))
}
else
{
opt
,
err
:=
credentials
.
NewServerTLSFromFile
(
c
.
GRPC
.
TLSCert
,
c
.
GRPC
.
TLSKey
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"load grpc certs: %v"
,
err
)
}
grpcOptions
=
append
(
grpcOptions
,
grpc
.
Creds
(
opt
))
}
grpcOptions
=
append
(
grpcOptions
,
grpc
.
Creds
(
opt
))
}
connectors
:=
make
([]
server
.
Connector
,
len
(
c
.
Connectors
))
...
...
This diff is collapsed.
Click to expand it.
examples/config-dev.yaml
+
1
−
0
View file @
74eaec60
...
...
@@ -22,6 +22,7 @@ web:
# addr: 127.0.0.1:5557
# tlsCert: /etc/dex/grpc.crt
# tlsKey: /etc/dex/grpc.key
# tlsClientCA: /etc/dex/client.crt
# Instead of reading from an external storage, use this list of clients.
#
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment