check if upstream contains preferrend username claim first

Signed-off-by: Rui Yang <ryang@pivotal.io>
Signed-off-by: Rui Yang <ruiya@vmware.com>
This commit is contained in:
Rui Yang 2020-08-05 21:50:33 -04:00 committed by Rui Yang
parent 4812079647
commit 52c39fb130

View File

@ -301,10 +301,10 @@ func (c *oidcConnector) createIdentity(ctx context.Context, identity connector.I
}
hostedDomain, _ := claims["hd"].(string)
if c.preferredUsernameKey == "" {
c.preferredUsernameKey = "preferred_username"
preferredUsername, found := claims["preferred_username"].(string)
if !found {
preferredUsername, _ = claims[c.preferredUsernameKey].(string)
}
preferredUsername, _ := claims[c.preferredUsernameKey].(string)
if len(c.hostedDomains) > 0 {
found := false