Skip to content

Commit

Permalink
fix: provide default for AZURE_AUTHORITY_HOST
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Apr 1, 2022
1 parent 29fb268 commit 760348b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/azure/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func AcquireToken(ctx context.Context, tenantID string) (string, func(tenantID, resource string) (*autorest.BearerAuthorizer, error), error) {
clientID := os.Getenv("AZURE_CLIENT_ID")
tokenFilePath := os.Getenv("AZURE_FEDERATED_TOKEN_FILE")
certFilePath := os.Getenv("AZURE_CLIENT_CERTIFICATE")
clientCert := os.Getenv("AZURE_CLIENT_CERTIFICATE")
clientSecret := os.Getenv("AZURE_CLIENT_SECRET")
appIDURI := os.Getenv("AZURE_APP_ID_URI")

Expand All @@ -21,7 +21,7 @@ func AcquireToken(ctx context.Context, tenantID string) (string, func(tenantID,

if clientSecret != "" {
return "token", AcquireTokenClientSecret(ctx, tenantID, appIDURI), nil
} else if certFilePath != "" {
} else if clientCert != "" {
return "token", AcquireTokenClientCertificate(ctx, tenantID, appIDURI), nil
} else if tokenFilePath != "" {
return "callack", AcquireTokenFederatedToken(ctx, tenantID), nil
Expand Down
5 changes: 4 additions & 1 deletion pkg/azure/client_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ func AcquireTokenClientSecret(ctx context.Context, tenantID, resource string) fu
return func(tenantID, resource string) (*autorest.BearerAuthorizer, error) {
clientID := os.Getenv("AZURE_CLIENT_ID")
clientSecret := os.Getenv("AZURE_CLIENT_SECRET")
authorityHost := os.Getenv("AZURE_AUTHORITY_HOST")
authorityHost := "https://login.microsoftonline.com"
if v := os.Getenv("AZURE_AUTHORITY_HOST"); v != "" {
authorityHost = v
}

// trim the suffix / if exists
resource = strings.TrimSuffix(resource, "/")
Expand Down
5 changes: 4 additions & 1 deletion pkg/azure/client_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ func AcquireTokenFederatedToken(ctx context.Context, tenantID string) func(tenan
// AZURE_AUTHORITY_HOST is the AAD authority hostname
clientID := os.Getenv("AZURE_CLIENT_ID")
tokenFilePath := os.Getenv("AZURE_FEDERATED_TOKEN_FILE")
authorityHost := os.Getenv("AZURE_AUTHORITY_HOST")
authorityHost := "https://login.microsoftonline.com"
if v := os.Getenv("AZURE_AUTHORITY_HOST"); v != "" {
authorityHost = v
}

// trim the suffix / if exists
resource = strings.TrimSuffix(resource, "/")
Expand Down

0 comments on commit 760348b

Please sign in to comment.