@@ -14,9 +14,10 @@ import (
14
14
"strings"
15
15
"time"
16
16
17
+ "golang.org/x/oauth2"
18
+
17
19
"github.com/dexidp/dex/connector"
18
20
"github.com/dexidp/dex/pkg/log"
19
- "golang.org/x/oauth2"
20
21
)
21
22
22
23
type oauthConnector struct {
@@ -113,7 +114,6 @@ func newHTTPClient(rootCAs []string, insecureSkipVerify bool) (*http.Client, err
113
114
}
114
115
115
116
func (c * oauthConnector ) LoginURL (scopes connector.Scopes , callbackURL , state string ) (string , error ) {
116
-
117
117
if c .redirectURI != callbackURL {
118
118
return "" , fmt .Errorf ("expected callback URL %q did not match the URL in the config %q" , callbackURL , c .redirectURI )
119
119
}
@@ -130,7 +130,6 @@ func (c *oauthConnector) LoginURL(scopes connector.Scopes, callbackURL, state st
130
130
}
131
131
132
132
func (c * oauthConnector ) HandleCallback (s connector.Scopes , r * http.Request ) (identity connector.Identity , err error ) {
133
-
134
133
q := r .URL .Query ()
135
134
if errType := q .Get ("error" ); errType != "" {
136
135
return identity , errors .New (q .Get ("error_description" ))
@@ -185,7 +184,7 @@ func (c *oauthConnector) HandleCallback(s connector.Scopes, r *http.Request) (id
185
184
186
185
identity .UserID , _ = userInfoResult [c .userIDKey ].(string )
187
186
identity .Username , _ = userInfoResult [c .userNameKey ].(string )
188
- identity .Name , _ = userInfoResult ["name" ].(string )
187
+ identity .PreferredUsername , _ = userInfoResult ["name" ].(string )
189
188
identity .Email , _ = userInfoResult ["email" ].(string )
190
189
identity .EmailVerified , _ = userInfoResult ["email_verified" ].(bool )
191
190
@@ -195,7 +194,7 @@ func (c *oauthConnector) HandleCallback(s connector.Scopes, r *http.Request) (id
195
194
c .addGroupsFromMap (groups , userInfoResult )
196
195
c .addGroupsFromToken (groups , token .AccessToken )
197
196
198
- for groupName , _ := range groups {
197
+ for groupName := range groups {
199
198
identity .Groups = append (identity .Groups , groupName )
200
199
}
201
200
}
@@ -215,7 +214,7 @@ func (c *oauthConnector) HandleCallback(s connector.Scopes, r *http.Request) (id
215
214
func (c * oauthConnector ) addGroupsFromMap (groups map [string ]bool , result map [string ]interface {}) error {
216
215
groupsClaim , ok := result [c .groupsKey ].([]interface {})
217
216
if ! ok {
218
- return errors .New ("Cant convert to array" )
217
+ return errors .New ("cant convert to array" )
219
218
}
220
219
221
220
for _ , group := range groupsClaim {
@@ -230,7 +229,7 @@ func (c *oauthConnector) addGroupsFromMap(groups map[string]bool, result map[str
230
229
func (c * oauthConnector ) addGroupsFromToken (groups map [string ]bool , token string ) error {
231
230
parts := strings .Split (token , "." )
232
231
if len (parts ) < 2 {
233
- return errors .New ("Invalid token" )
232
+ return errors .New ("invalid token" )
234
233
}
235
234
236
235
decoded , err := decode (parts [1 ])
0 commit comments