Skip to content

Commit

Permalink
Get scope from endpoint url instead of hardcoding (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
rqi14 authored Apr 2, 2024
1 parent 23a1473 commit 9af532f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion management/server/idp/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@ func (ac *AzureCredentials) requestJWTToken() (*http.Response, error) {
data.Set("client_id", ac.clientConfig.ClientID)
data.Set("client_secret", ac.clientConfig.ClientSecret)
data.Set("grant_type", ac.clientConfig.GrantType)
data.Set("scope", "https://graph.microsoft.com/.default")
parsedURL, err := url.Parse(ac.clientConfig.GraphAPIEndpoint)
if err != nil {
return nil, err
}

// get base url and add "/.default" as scope
baseURL := parsedURL.Scheme + "://" + parsedURL.Host
scopeURL := baseURL + "/.default"
data.Set("scope", scopeURL)

payload := strings.NewReader(data.Encode())
req, err := http.NewRequest(http.MethodPost, ac.clientConfig.TokenEndpoint, payload)
Expand Down

0 comments on commit 9af532f

Please sign in to comment.