Skip to content

Commit

Permalink
Use trace.NotFound when returning an error.
Browse files Browse the repository at this point in the history
  • Loading branch information
russjones committed Apr 13, 2017
1 parent 2acff45 commit 9df3b48
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,15 +920,16 @@ func claimsFromUserInfo(oidcClient *oidc.Client, issuerURL string, accessToken s
}
hc := oac.HttpClient()

// go get the provider config so we can find out where the UserInfo endpoint is
// go get the provider config so we can find out where the UserInfo endpoint
// is. if the provider doesn't offer a UserInfo endpoint return not found.
pc, err := oidc.FetchProviderConfig(oac.HttpClient(), issuerURL)
if err != nil {
return nil, trace.Wrap(err)
}
// If the provider doesn't offer a UserInfo endpoint don't err.
if pc.UserInfoEndpoint == nil {
return nil, nil
return nil, trace.NotFound("UserInfo endpoint not found")
}

endpoint := pc.UserInfoEndpoint.String()
err = isHTTPS(endpoint)
if err != nil {
Expand Down Expand Up @@ -996,14 +997,13 @@ func (a *AuthServer) getClaims(oidcClient *oidc.Client, issuerURL string, code s

userInfoClaims, err := claimsFromUserInfo(oidcClient, issuerURL, t.AccessToken)
if err != nil {
if trace.IsNotFound(err) {
log.Debugf("[OIDC] Provider doesn't offer UserInfo endpoint. Returning token claims: %v", idTokenClaims)
return idTokenClaims, nil
}
log.Debugf("[OIDC] Unable to fetch UserInfo claims: %v", err)
return nil, trace.Wrap(err)
}
if userInfoClaims == nil {
log.Warn("[OIDC] Provider doesn't offer UserInfo endpoint. Only token claims will be used.")
return idTokenClaims, nil
}

log.Debugf("[OIDC] UserInfo claims: %v", userInfoClaims)

// make sure that the subject in the userinfo claim matches the subject in
Expand Down

0 comments on commit 9df3b48

Please sign in to comment.