@@ -191,16 +191,14 @@ func (c *oauthConnector) HandleCallback(s connector.Scopes, r *http.Request) (id
191
191
if err != nil {
192
192
return identity , fmt .Errorf ("OAuth Connector: failed to execute request to userinfo: %v" , err )
193
193
}
194
+ defer userInfoResp .Body .Close ()
194
195
195
196
if userInfoResp .StatusCode != http .StatusOK {
196
197
return identity , fmt .Errorf ("OAuth Connector: failed to execute request to userinfo: status %d" , userInfoResp .StatusCode )
197
198
}
198
199
199
- defer userInfoResp .Body .Close ()
200
-
201
200
var userInfoResult map [string ]interface {}
202
201
err = json .NewDecoder (userInfoResp .Body ).Decode (& userInfoResult )
203
-
204
202
if err != nil {
205
203
return identity , fmt .Errorf ("OAuth Connector: failed to parse userinfo: %v" , err )
206
204
}
@@ -217,7 +215,7 @@ func (c *oauthConnector) HandleCallback(s connector.Scopes, r *http.Request) (id
217
215
identity .EmailVerified , _ = userInfoResult [c .emailVerifiedKey ].(bool )
218
216
219
217
if s .Groups {
220
- groups := map [string ]bool {}
218
+ groups := map [string ]struct {} {}
221
219
222
220
c .addGroupsFromMap (groups , userInfoResult )
223
221
c .addGroupsFromToken (groups , token .AccessToken )
@@ -239,22 +237,22 @@ func (c *oauthConnector) HandleCallback(s connector.Scopes, r *http.Request) (id
239
237
return identity , nil
240
238
}
241
239
242
- func (c * oauthConnector ) addGroupsFromMap (groups map [string ]bool , result map [string ]interface {}) error {
240
+ func (c * oauthConnector ) addGroupsFromMap (groups map [string ]struct {} , result map [string ]interface {}) error {
243
241
groupsClaim , ok := result [c .groupsKey ].([]interface {})
244
242
if ! ok {
245
243
return errors .New ("cannot convert to slice" )
246
244
}
247
245
248
246
for _ , group := range groupsClaim {
249
247
if groupString , ok := group .(string ); ok {
250
- groups [groupString ] = true
248
+ groups [groupString ] = struct {}{}
251
249
}
252
250
}
253
251
254
252
return nil
255
253
}
256
254
257
- func (c * oauthConnector ) addGroupsFromToken (groups map [string ]bool , token string ) error {
255
+ func (c * oauthConnector ) addGroupsFromToken (groups map [string ]struct {} , token string ) error {
258
256
parts := strings .Split (token , "." )
259
257
if len (parts ) < 2 {
260
258
return errors .New ("invalid token" )
0 commit comments