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
4550b95d
Commit
4550b95d
authored
Oct 04, 2016
by
Eric Chiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/dex: add config options for gRPC
parent
8b079168
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
6 deletions
+45
-6
config.go
cmd/dex/config.go
+9
-0
init.go
cmd/dex/init.go
+0
-1
serve.go
cmd/dex/serve.go
+36
-5
No files found.
cmd/dex/config.go
View file @
4550b95d
...
...
@@ -22,6 +22,7 @@ type Config struct {
Connectors
[]
Connector
`yaml:"connectors"`
Web
Web
`yaml:"web"`
OAuth2
OAuth2
`yaml:"oauth2"`
GRPC
GRPC
`yaml:"grpc"`
Templates
server
.
TemplateConfig
`yaml:"templates"`
...
...
@@ -41,6 +42,14 @@ type Web struct {
TLSKey
string
`yaml:"tlsKey"`
}
// 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"`
}
// Storage holds app's storage configuration.
type
Storage
struct
{
Type
string
`yaml:"type"`
...
...
cmd/dex/init.go
deleted
100644 → 0
View file @
8b079168
package
main
cmd/dex/serve.go
View file @
4550b95d
...
...
@@ -5,11 +5,15 @@ import (
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
yaml
"gopkg.in/yaml.v2"
"github.com/coreos/dex/api"
"github.com/coreos/dex/server"
"github.com/coreos/dex/storage"
)
...
...
@@ -19,7 +23,7 @@ func commandServe() *cobra.Command {
Use
:
"serve [ config file ]"
,
Short
:
"Connect to the storage and begin serving requests."
,
Long
:
``
,
Example
:
"dex serve c.yaml"
,
Example
:
"dex serve c
onfig
.yaml"
,
RunE
:
serve
,
}
}
...
...
@@ -56,6 +60,9 @@ func serve(cmd *cobra.Command, args []string) error {
{
c
.
Web
.
HTTP
==
""
&&
c
.
Web
.
HTTPS
==
""
,
"must supply a HTTP/HTTPS address to listen on"
},
{
c
.
Web
.
HTTPS
!=
""
&&
c
.
Web
.
TLSCert
==
""
,
"no cert specified for HTTPS"
},
{
c
.
Web
.
HTTPS
!=
""
&&
c
.
Web
.
TLSKey
==
""
,
"no private key specified for HTTPS"
},
{
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"
},
}
for
_
,
check
:=
range
checks
{
...
...
@@ -64,6 +71,15 @@ 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
)
}
grpcOptions
=
append
(
grpcOptions
,
grpc
.
Creds
(
opt
))
}
connectors
:=
make
([]
server
.
Connector
,
len
(
c
.
Connectors
))
for
i
,
conn
:=
range
c
.
Connectors
{
if
conn
.
Config
==
nil
{
...
...
@@ -96,22 +112,37 @@ func serve(cmd *cobra.Command, args []string) error {
TemplateConfig
:
c
.
Templates
,
}
serv
,
err
:=
server
.
New
(
serverConfig
)
serv
,
err
:=
server
.
New
Server
(
serverConfig
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"initializing server: %v"
,
err
)
}
errc
:=
make
(
chan
error
,
2
)
errc
:=
make
(
chan
error
,
3
)
if
c
.
Web
.
HTTP
!=
""
{
log
.
Printf
(
"listening (http) on %s"
,
c
.
Web
.
HTTP
)
go
func
()
{
log
.
Printf
(
"listening on %s"
,
c
.
Web
.
HTTP
)
errc
<-
http
.
ListenAndServe
(
c
.
Web
.
HTTP
,
serv
)
}()
}
if
c
.
Web
.
HTTPS
!=
""
{
log
.
Printf
(
"listening (https) on %s"
,
c
.
Web
.
HTTPS
)
go
func
()
{
log
.
Printf
(
"listening on %s"
,
c
.
Web
.
HTTPS
)
errc
<-
http
.
ListenAndServeTLS
(
c
.
Web
.
HTTPS
,
c
.
Web
.
TLSCert
,
c
.
Web
.
TLSKey
,
serv
)
}()
}
if
c
.
GRPC
.
Addr
!=
""
{
log
.
Printf
(
"listening (grpc) on %s"
,
c
.
GRPC
.
Addr
)
go
func
()
{
errc
<-
func
()
error
{
list
,
err
:=
net
.
Listen
(
"tcp"
,
c
.
GRPC
.
Addr
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"listen grpc: %v"
,
err
)
}
s
:=
grpc
.
NewServer
(
grpcOptions
...
)
api
.
RegisterDexServer
(
s
,
server
.
NewAPI
(
serverConfig
.
Storage
))
return
s
.
Serve
(
list
)
}()
}()
}
return
<-
errc
}
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