|
|
|
|
@ -58,6 +58,9 @@ type Config struct {
|
|
|
|
|
// Configurable key which contains the preferred username claims
|
|
|
|
|
PreferredUsernameKey string `json:"preferredUsernameKey"` |
|
|
|
|
|
|
|
|
|
// EmailClaim override email claim key. Defaults to "email"
|
|
|
|
|
EmailClaim string `json:"emailClaim"` |
|
|
|
|
|
|
|
|
|
// PromptType will be used fot the prompt parameter (when offline_access, by default prompt=consent)
|
|
|
|
|
PromptType string `json:"promptType"` |
|
|
|
|
} |
|
|
|
|
@ -112,6 +115,11 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
|
|
|
|
|
endpoint.AuthStyle = oauth2.AuthStyleInParams |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
emailClaim := "email" |
|
|
|
|
if len(c.EmailClaim) > 0 { |
|
|
|
|
emailClaim = c.EmailClaim |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
scopes := []string{oidc.ScopeOpenID} |
|
|
|
|
if len(c.Scopes) > 0 { |
|
|
|
|
scopes = append(scopes, c.Scopes...) |
|
|
|
|
@ -147,6 +155,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
|
|
|
|
|
userIDKey: c.UserIDKey, |
|
|
|
|
userNameKey: c.UserNameKey, |
|
|
|
|
preferredUsernameKey: c.PreferredUsernameKey, |
|
|
|
|
emailClaim: emailClaim, |
|
|
|
|
promptType: c.PromptType, |
|
|
|
|
}, nil |
|
|
|
|
} |
|
|
|
|
@ -170,6 +179,7 @@ type oidcConnector struct {
|
|
|
|
|
userIDKey string |
|
|
|
|
userNameKey string |
|
|
|
|
preferredUsernameKey string |
|
|
|
|
emailClaim string |
|
|
|
|
promptType string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -286,9 +296,9 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
email, found := claims["email"].(string) |
|
|
|
|
email, found := claims[c.emailClaim].(string) |
|
|
|
|
if !found && hasEmailScope { |
|
|
|
|
return identity, errors.New("missing \"email\" claim") |
|
|
|
|
return identity, fmt.Errorf("missing \"%s\" claim", c.emailClaim) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
emailVerified, found := claims["email_verified"].(bool) |
|
|
|
|
|