small refactors and cleanup
Signed-off-by: Rui Yang <ruiya@vmware.com>
This commit is contained in:
parent
8b865169bd
commit
539e08ba50
@ -81,7 +81,6 @@ Dex implements the following connectors:
|
||||
| [Atlassian Crowd](https://dexidp.io/docs/connectors/atlassiancrowd/) | yes | yes | yes * | beta | preferred_username claim must be configured through config |
|
||||
| [Gitea](https://dexidp.io/docs/connectors/gitea/) | yes | no | yes | alpha | |
|
||||
| [OpenStack Keystone](https://dexidp.io/docs/connectors/keystone/) | yes | yes | no | alpha | |
|
||||
| [Generic OAuth 2.0](https://dexidp.io/docs/connectors/oauth/) | no | yes | yes | alpha | |
|
||||
|
||||
Stable, beta, and alpha are defined as:
|
||||
|
||||
|
@ -65,28 +65,34 @@ type Config struct {
|
||||
func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error) {
|
||||
var err error
|
||||
|
||||
if c.UserIDKey == "" {
|
||||
c.UserIDKey = "id"
|
||||
userIDKey := c.UserIDKey
|
||||
if userIDKey == "" {
|
||||
userIDKey = "id"
|
||||
}
|
||||
|
||||
if c.ClaimMapping.UserNameKey == "" {
|
||||
c.ClaimMapping.UserNameKey = "user_name"
|
||||
userNameKey := c.ClaimMapping.UserNameKey
|
||||
if userNameKey == "" {
|
||||
userNameKey = "user_name"
|
||||
}
|
||||
|
||||
if c.ClaimMapping.PreferredUsernameKey == "" {
|
||||
c.ClaimMapping.PreferredUsernameKey = "preferred_username"
|
||||
preferredUsernameKey := c.ClaimMapping.PreferredUsernameKey
|
||||
if preferredUsernameKey == "" {
|
||||
preferredUsernameKey = "preferred_username"
|
||||
}
|
||||
|
||||
if c.ClaimMapping.GroupsKey == "" {
|
||||
c.ClaimMapping.GroupsKey = "groups"
|
||||
groupsKey := c.ClaimMapping.GroupsKey
|
||||
if groupsKey == "" {
|
||||
groupsKey = "groups"
|
||||
}
|
||||
|
||||
if c.ClaimMapping.EmailKey == "" {
|
||||
c.ClaimMapping.EmailKey = "email"
|
||||
emailKey := c.ClaimMapping.EmailKey
|
||||
if emailKey == "" {
|
||||
emailKey = "email"
|
||||
}
|
||||
|
||||
if c.ClaimMapping.EmailVerifiedKey == "" {
|
||||
c.ClaimMapping.EmailVerifiedKey = "email_verified"
|
||||
emailVerifiedKey := c.ClaimMapping.EmailVerifiedKey
|
||||
if emailVerifiedKey == "" {
|
||||
emailVerifiedKey = "email_verified"
|
||||
}
|
||||
|
||||
oauthConn := &oauthConnector{
|
||||
@ -98,12 +104,12 @@ func (c *Config) Open(id string, logger log.Logger) (connector.Connector, error)
|
||||
scopes: c.Scopes,
|
||||
redirectURI: c.RedirectURI,
|
||||
logger: logger,
|
||||
userIDKey: c.UserIDKey,
|
||||
userNameKey: c.ClaimMapping.UserNameKey,
|
||||
preferredUsernameKey: c.ClaimMapping.PreferredUsernameKey,
|
||||
groupsKey: c.ClaimMapping.GroupsKey,
|
||||
emailKey: c.ClaimMapping.EmailKey,
|
||||
emailVerifiedKey: c.ClaimMapping.EmailVerifiedKey,
|
||||
userIDKey: userIDKey,
|
||||
userNameKey: userNameKey,
|
||||
preferredUsernameKey: preferredUsernameKey,
|
||||
groupsKey: groupsKey,
|
||||
emailKey: emailKey,
|
||||
emailVerifiedKey: emailVerifiedKey,
|
||||
}
|
||||
|
||||
oauthConn.httpClient, err = newHTTPClient(c.RootCAs, c.InsecureSkipVerify)
|
||||
|
Reference in New Issue
Block a user