Skip to content

Commit

Permalink
AzureCLICredential respects application deadlines (#19734)
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell authored Jan 3, 2023
1 parent 073769b commit ab5b4fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions sdk/azidentity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
### Bugs Fixed

### Other Changes
* `AzureCLICredential` imposes its default timeout only when the `Context`
passed to `GetToken()` has no deadline

## 1.3.0-beta.1 (2022-12-13)

Expand Down
8 changes: 6 additions & 2 deletions sdk/azidentity/azure_cli_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ func defaultTokenProvider() func(ctx context.Context, resource string, tenantID
return nil, fmt.Errorf(`%s: unexpected scope "%s". Only alphanumeric characters and ".", ";", "-", and "/" are allowed`, credNameAzureCLI, resource)
}

ctx, cancel := context.WithTimeout(ctx, timeoutCLIRequest)
defer cancel()
// set a default timeout for this authentication iff the application hasn't done so already
var cancel context.CancelFunc
if _, hasDeadline := ctx.Deadline(); !hasDeadline {
ctx, cancel = context.WithTimeout(ctx, timeoutCLIRequest)
defer cancel()
}

commandLine := "az account get-access-token -o json --resource " + resource
if tenantID != "" {
Expand Down

0 comments on commit ab5b4fb

Please sign in to comment.