diff --git a/README.md b/README.md index 5e18e515..b69bdc0a 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/connector/oauth/oauth.go b/connector/oauth/oauth.go index 55527670..e37932ad 100644 --- a/connector/oauth/oauth.go +++ b/connector/oauth/oauth.go @@ -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)