Auth: Validate Azure ID token version on login is not v1 (#58088)

This commit is contained in:
Jo
2022-11-03 09:47:44 +01:00
committed by GitHub
parent 77f47ccba3
commit eb84358aa7
+5
View File
@@ -31,6 +31,7 @@ type azureClaims struct {
ClaimNames claimNames `json:"_claim_names,omitempty"`
ClaimSources map[string]claimSource `json:"_claim_sources,omitempty"`
TenantID string `json:"tid,omitempty"`
OAuthVersion string `json:"ver,omitempty"`
}
type claimNames struct {
@@ -65,6 +66,10 @@ func (s *SocialAzureAD) UserInfo(client *http.Client, token *oauth2.Token) (*Bas
return nil, fmt.Errorf("error getting claims from id token: %w", err)
}
if claims.OAuthVersion == "1.0" {
return nil, &Error{"AzureAD OAuth: version 1.0 is not supported. Please ensure the auth_url and token_url are set to the v2.0 endpoints."}
}
email := claims.extractEmail()
if email == "" {
return nil, ErrEmailNotFound