@@ -42,6 +42,9 @@ type Config struct {
4242 // Override the value of email_verifed to true in the returned claims
4343 InsecureSkipEmailVerified bool `json:"insecureSkipEmailVerified"`
4444
45+ // InsecureEnableGroups enables groups claims. This is disabled by default until https://github.com/dexidp/dex/issues/1065 is resolved
46+ InsecureEnableGroups bool `json:"insecureEnableGroups"`
47+
4548 // GetUserInfo uses the userinfo endpoint to get additional claims for
4649 // the token. This is especially useful where upstreams return "thin"
4750 // id tokens
@@ -139,6 +142,7 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
139142 cancel : cancel ,
140143 hostedDomains : c .HostedDomains ,
141144 insecureSkipEmailVerified : c .InsecureSkipEmailVerified ,
145+ insecureEnableGroups : c .InsecureEnableGroups ,
142146 getUserInfo : c .GetUserInfo ,
143147 userIDKey : c .UserIDKey ,
144148 userNameKey : c .UserNameKey ,
@@ -159,6 +163,7 @@ type oidcConnector struct {
159163 logger log.Logger
160164 hostedDomains []string
161165 insecureSkipEmailVerified bool
166+ insecureEnableGroups bool
162167 getUserInfo bool
163168 userIDKey string
164169 userNameKey string
@@ -321,5 +326,18 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
321326 identity .UserID = userID
322327 }
323328
329+ if c .insecureEnableGroups {
330+ vs , ok := claims ["groups" ].([]interface {})
331+ if ok {
332+ for _ , v := range vs {
333+ if s , ok := v .(string ); ok {
334+ identity .Groups = append (identity .Groups , s )
335+ } else {
336+ return identity , errors .New ("malformed \" groups\" claim" )
337+ }
338+ }
339+ }
340+ }
341+
324342 return identity , nil
325343}
0 commit comments