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
6f98dfeb
Commit
6f98dfeb
authored
Jun 03, 2016
by
abrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added TLS support to the example application
parent
4440b3a0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
main.go
examples/app/main.go
+19
-4
No files found.
examples/app/main.go
View file @
6f98dfeb
...
@@ -31,6 +31,9 @@ func main() {
...
@@ -31,6 +31,9 @@ func main() {
clientSecret
:=
fs
.
String
(
"client-secret"
,
"ZXhhbXBsZS1hcHAtc2VjcmV0"
,
""
)
clientSecret
:=
fs
.
String
(
"client-secret"
,
"ZXhhbXBsZS1hcHAtc2VjcmV0"
,
""
)
caFile
:=
fs
.
String
(
"trusted-ca-file"
,
""
,
"the TLS CA file, if empty then the host's root CA will be used"
)
caFile
:=
fs
.
String
(
"trusted-ca-file"
,
""
,
"the TLS CA file, if empty then the host's root CA will be used"
)
certFile
:=
fs
.
String
(
"tls-cert-file"
,
""
,
"the TLS cert file. If empty, the app will listen on HTTP"
)
keyFile
:=
fs
.
String
(
"tls-key-file"
,
""
,
"the TLS key file. If empty, the app will listen on HTTP"
)
discovery
:=
fs
.
String
(
"discovery"
,
"http://127.0.0.1:5556"
,
""
)
discovery
:=
fs
.
String
(
"discovery"
,
"http://127.0.0.1:5556"
,
""
)
logDebug
:=
fs
.
Bool
(
"log-debug"
,
false
,
"log debug-level information"
)
logDebug
:=
fs
.
Bool
(
"log-debug"
,
false
,
"log debug-level information"
)
logTimestamps
:=
fs
.
Bool
(
"log-timestamps"
,
false
,
"prefix log lines with timestamps"
)
logTimestamps
:=
fs
.
Bool
(
"log-timestamps"
,
false
,
"prefix log lines with timestamps"
)
...
@@ -70,6 +73,16 @@ func main() {
...
@@ -70,6 +73,16 @@ func main() {
log
.
Fatalf
(
"Unable to parse host from --listen flag: %v"
,
err
)
log
.
Fatalf
(
"Unable to parse host from --listen flag: %v"
,
err
)
}
}
redirectURLParsed
,
err
:=
url
.
Parse
(
*
redirectURL
)
if
err
!=
nil
{
log
.
Fatalf
(
"Unable to parse url from --redirect-url flag: %v"
,
err
)
}
useTLS
:=
*
keyFile
!=
""
&&
*
certFile
!=
""
if
useTLS
&&
(
redirectURLParsed
.
Scheme
!=
"https"
||
l
.
Scheme
!=
"https"
)
{
log
.
Fatalf
(
"TLS Cert File and Key File were provided. Ensure the listen and redirect URL are using HTTPS."
)
}
cc
:=
oidc
.
ClientCredentials
{
cc
:=
oidc
.
ClientCredentials
{
ID
:
*
clientID
,
ID
:
*
clientID
,
Secret
:
*
clientSecret
,
Secret
:
*
clientSecret
,
...
@@ -117,10 +130,6 @@ func main() {
...
@@ -117,10 +130,6 @@ func main() {
client
.
SyncProviderConfig
(
*
discovery
)
client
.
SyncProviderConfig
(
*
discovery
)
redirectURLParsed
,
err
:=
url
.
Parse
(
*
redirectURL
)
if
err
!=
nil
{
log
.
Fatalf
(
"Unable to parse url from --redirect-url flag: %v"
,
err
)
}
hdlr
:=
NewClientHandler
(
client
,
*
discovery
,
*
redirectURLParsed
)
hdlr
:=
NewClientHandler
(
client
,
*
discovery
,
*
redirectURLParsed
)
httpsrv
:=
&
http
.
Server
{
httpsrv
:=
&
http
.
Server
{
Addr
:
fmt
.
Sprintf
(
":%s"
,
p
),
Addr
:
fmt
.
Sprintf
(
":%s"
,
p
),
...
@@ -128,7 +137,13 @@ func main() {
...
@@ -128,7 +137,13 @@ func main() {
}
}
log
.
Infof
(
"Binding to %s..."
,
httpsrv
.
Addr
)
log
.
Infof
(
"Binding to %s..."
,
httpsrv
.
Addr
)
if
useTLS
{
log
.
Info
(
"Key and cert file provided. Using TLS"
)
log
.
Fatal
(
httpsrv
.
ListenAndServeTLS
(
*
certFile
,
*
keyFile
))
}
else
{
log
.
Fatal
(
httpsrv
.
ListenAndServe
())
log
.
Fatal
(
httpsrv
.
ListenAndServe
())
}
}
}
func
NewClientHandler
(
c
*
oidc
.
Client
,
issuer
string
,
cbURL
url
.
URL
)
http
.
Handler
{
func
NewClientHandler
(
c
*
oidc
.
Client
,
issuer
string
,
cbURL
url
.
URL
)
http
.
Handler
{
...
...
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