Azure OAuth: silent fail on getting groups (#49909)

This commit is contained in:
Gabriel MABILLE 2022-06-01 17:10:47 +02:00 committed by GitHub
parent e5fab2dec8
commit 3049534c40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"strings"
@ -214,9 +215,11 @@ func extractGroups(client *http.Client, claims azureClaims, token *oauth2.Token)
if res.StatusCode != http.StatusOK {
if res.StatusCode == http.StatusForbidden {
logger.Warn("AzureAD OAuh: Token need GroupMember.Read.All permission to fetch all groups")
return []string{}, nil
} else {
body, _ := io.ReadAll(res.Body)
logger.Warn("AzureAD OAuh: could not fetch user groups", "code", res.StatusCode, "body", string(body))
}
return nil, errors.New("error fetching groups")
return []string{}, nil
}
var body getAzureGroupResponse