Skip to content

Commit

Permalink
Ops: Update azure cloud token auth
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaiandreiratoiu committed Aug 18, 2023
1 parent 0518e84 commit e1822c2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions oci/auth/azure/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,16 @@ func (c *Client) getLoginAuth(ctx context.Context, registryURL string) (authn.Au
c.credential = cred
}

var configurationEnvironmentLookupMap = map[string]cloud.Configuration{
"io": cloud.AzurePublic,
"de": cloud.AzurePublic, // Azure Germany is not supported by Azure SDK for Go
"us": cloud.AzureGovernment,
"cn": cloud.AzureChina,
}
var azureEndpoint = registryURL[len(registryURL)-2:]
// Obtain access token using the token credential.
// TODO: Add support for other azure endpoints as well.
armToken, err := c.credential.GetToken(ctx, policy.TokenRequestOptions{
Scopes: []string{cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + "/" + ".default"},
Scopes: []string{configurationEnvironmentLookupMap[azureEndpoint].Services[cloud.ResourceManager].Endpoint + "/" + ".default"},
})
if err != nil {
return authConfig, err
Expand Down

0 comments on commit e1822c2

Please sign in to comment.