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
4194530c
Commit
4194530c
authored
Jun 21, 2017
by
Ben Navetta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial hostedDomain support
parent
3493e30f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
oidc.go
connector/oidc/oidc.go
+13
-0
No files found.
connector/oidc/oidc.go
View file @
4194530c
...
@@ -33,6 +33,7 @@ type Config struct {
...
@@ -33,6 +33,7 @@ type Config struct {
Scopes
[]
string
`json:"scopes"`
// defaults to "profile" and "email"
Scopes
[]
string
`json:"scopes"`
// defaults to "profile" and "email"
HostedDomain
string
`json:"hostedDomain"`
}
}
// Domains that don't support basic auth. golang.org/x/oauth2 has an internal
// Domains that don't support basic auth. golang.org/x/oauth2 has an internal
...
@@ -112,6 +113,7 @@ func (c *Config) Open(logger logrus.FieldLogger) (conn connector.Connector, err
...
@@ -112,6 +113,7 @@ func (c *Config) Open(logger logrus.FieldLogger) (conn connector.Connector, err
),
),
logger
:
logger
,
logger
:
logger
,
cancel
:
cancel
,
cancel
:
cancel
,
hostedDomain
:
c
.
HostedDomain
,
},
nil
},
nil
}
}
...
@@ -127,6 +129,7 @@ type oidcConnector struct {
...
@@ -127,6 +129,7 @@ type oidcConnector struct {
ctx
context
.
Context
ctx
context
.
Context
cancel
context
.
CancelFunc
cancel
context
.
CancelFunc
logger
logrus
.
FieldLogger
logger
logrus
.
FieldLogger
hostedDomain
string
}
}
func
(
c
*
oidcConnector
)
Close
()
error
{
func
(
c
*
oidcConnector
)
Close
()
error
{
...
@@ -138,7 +141,12 @@ func (c *oidcConnector) LoginURL(s connector.Scopes, callbackURL, state string)
...
@@ -138,7 +141,12 @@ func (c *oidcConnector) LoginURL(s connector.Scopes, callbackURL, state string)
if
c
.
redirectURI
!=
callbackURL
{
if
c
.
redirectURI
!=
callbackURL
{
return
""
,
fmt
.
Errorf
(
"expected callback URL %q did not match the URL in the config %q"
,
callbackURL
,
c
.
redirectURI
)
return
""
,
fmt
.
Errorf
(
"expected callback URL %q did not match the URL in the config %q"
,
callbackURL
,
c
.
redirectURI
)
}
}
if
c
.
hostedDomain
!=
""
{
return
c
.
oauth2Config
.
AuthCodeURL
(
state
,
oauth2
.
SetAuthURLParam
(
"hd"
,
c
.
hostedDomain
)),
nil
}
else
{
return
c
.
oauth2Config
.
AuthCodeURL
(
state
),
nil
return
c
.
oauth2Config
.
AuthCodeURL
(
state
),
nil
}
}
}
type
oauth2Error
struct
{
type
oauth2Error
struct
{
...
@@ -176,11 +184,16 @@ func (c *oidcConnector) HandleCallback(s connector.Scopes, r *http.Request) (ide
...
@@ -176,11 +184,16 @@ func (c *oidcConnector) HandleCallback(s connector.Scopes, r *http.Request) (ide
Username
string
`json:"name"`
Username
string
`json:"name"`
Email
string
`json:"email"`
Email
string
`json:"email"`
EmailVerified
bool
`json:"email_verified"`
EmailVerified
bool
`json:"email_verified"`
HostedDomain
string
`json:"hd"`
}
}
if
err
:=
idToken
.
Claims
(
&
claims
);
err
!=
nil
{
if
err
:=
idToken
.
Claims
(
&
claims
);
err
!=
nil
{
return
identity
,
fmt
.
Errorf
(
"oidc: failed to decode claims: %v"
,
err
)
return
identity
,
fmt
.
Errorf
(
"oidc: failed to decode claims: %v"
,
err
)
}
}
if
claims
.
HostedDomain
!=
c
.
hostedDomain
{
return
identity
,
fmt
.
Errorf
(
"oidc: unexpected hd claim %v"
,
claims
.
HostedDomain
)
}
identity
=
connector
.
Identity
{
identity
=
connector
.
Identity
{
UserID
:
idToken
.
Subject
,
UserID
:
idToken
.
Subject
,
Username
:
claims
.
Username
,
Username
:
claims
.
Username
,
...
...
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