fix: add email query to github idp if email empty (#10705)

# Which Problems Are Solved

In the integration with Github, private emails are not returned with the
userinfo.

# How the Problems Are Solved

If the scope `user:email` is set in the Github IDP and the email is not
included in the userinfo, a request to Github's API is executed to query
the email of the user.

# Additional Changes

Additional tests.

# Additional Context

Closes #10098

---------

Co-authored-by: Marco A. <[email protected]>
Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
Stefan Benz
2025-10-07 06:13:06 +00:00
committed by GitHub
co-authored by Marco A. Livio Spring
parent 695db96745
commit a7e1bfb4a3
7 changed files with 458 additions and 42 deletions
@@ -321,14 +321,14 @@ func (l *Login) handleExternalLoginCallback(w http.ResponseWriter, r *http.Reque
l.externalAuthCallbackFailed(w, r, authReq, nil, nil, err)
return
}
session = oauth.NewSession(provider.Provider, data.Code, authReq.SelectedIDPConfigArgs)
session = github.NewSession(provider, data.Code, authReq.SelectedIDPConfigArgs)
case domain.IDPTypeGitHubEnterprise:
provider, err := l.githubEnterpriseProvider(r.Context(), identityProvider)
if err != nil {
l.externalAuthCallbackFailed(w, r, authReq, nil, nil, err)
return
}
session = oauth.NewSession(provider.Provider, data.Code, authReq.SelectedIDPConfigArgs)
session = github.NewSession(provider, data.Code, authReq.SelectedIDPConfigArgs)
case domain.IDPTypeGitLab:
provider, err := l.gitlabProvider(r.Context(), identityProvider)
if err != nil {
@@ -1324,6 +1324,8 @@ func tokens(session idp.Session) *oidc.Tokens[*oidc.IDTokenClaims] {
return s.Tokens
case *oauth.Session:
return s.Tokens
case *github.Session:
return s.Tokens()
case *azuread.Session:
return s.Tokens()
case *apple.Session: