-
Notifications
You must be signed in to change notification settings - Fork 14
fix: Fixed azure cli authorization #461
base: main
Are you sure you want to change the base?
Conversation
@@ -72,6 +73,10 @@ func Configure(logger hclog.Logger, config interface{}) (schema.ClientMeta, diag | |||
logger.Info("Trying to authenticate via CLI (azidentity)") | |||
var azCred azcore.TokenCredential | |||
azCred, err = azidentity.NewAzureCLICredential(nil) | |||
if err == nil { | |||
// check token generation | |||
_, err = azCred.GetToken(context.Background(), policy.TokenRequestOptions{Scopes: []string{"https://management.core.windows.net//.default"}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I'm reading the error message from the original issue more carefully now, and it suggests that the issue was that the az
CLI wasn't found on the path. So what you're doing here is checking that we can auth using that method, and if not, falling through to environment variables. I see! I still think we may want to use a ChainedTokenCredential
instead, so that the Azure SDK will go through all the auth options for us if one fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amanenk I also made an attempted fix here, using the default credential chain: cloudquery/cloudquery#1283
Let's chat about how we want to proceed: perhaps we can release your fix as a release here (the final one to be released on this repo), and the default credential one only on the monorepo, since that's also a breaking change.
Summary
closes cloudquery/cloudquery#1221
Use the following steps to ensure your PR is ready to be reviewed
go fmt
to format your code πgolangci-lint run
π¨ (install golangci-lint here)go run ./docs/docs.go
and committing the changes π