Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

az cli returns expiresOn in local time but sdk assumes c++ time #5075

Closed
3 tasks done
janbernloehr opened this issue Oct 26, 2023 · 0 comments · Fixed by #5179
Closed
3 tasks done

az cli returns expiresOn in local time but sdk assumes c++ time #5075

janbernloehr opened this issue Oct 26, 2023 · 0 comments · Fixed by #5179
Assignees
Labels
Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team

Comments

@janbernloehr
Copy link

Describe the bug
When using an AzureCliCredential, the ExpiresOn field is parsed from the the output of the call

az account get-access-token --output json --scope "https://storage.azure.com/.default"

which returns the field expiresOn in local time but does not add time zone information. However, Azure::DateTime assumes - when no time zone information is present - that the date is in UTC.

The IsFresh method of Azure::TokenCache then compares the parsed ExpiresOn with Azure::DateTime(std::chrono::system_clock::now()) which is UTC time thus yielding a wrong comparison.

Exception or Stack Trace

To Reproduce
Steps to reproduce the behavior:
Inject the following debug code in TokenCache::IsFresh in token_cache.cpp:

  const DateTime end_point = DateTime(now) + minimumExpiration;
  std::cout << "lhs: " << item->AccessToken.ExpiresOn.ToString() << " rhs: " << end_point.ToString() << std::endl;

Then call any api using the AzureCliCredential that requires a token.

Code Snippet

Expected behavior
The AzureCliCredential should correctly take the time zone information into account.

Screenshots

Setup (please complete the following information):

  • OS: Ubuntu 22.04
  • IDE : VsCode
  • Version of the Library used: Azure Identity 1.6.0-beta.1 and Azure Core 1.10.2

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 26, 2023
@RickWinter RickWinter added Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Oct 30, 2023
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Oct 30, 2023
maorleger added a commit to Azure/azure-sdk-for-js that referenced this issue Jan 24, 2024
### Packages impacted by this PR

@azure/identity

### Issues associated with this PR

Resolves #27648

### Describe the problem that is addressed by this PR

In version 2.54.0 the Azure CLI started including an `expires_on` field
containing a POSIX timestamp in seconds in addition to the existing
`expiresOn` field denoting the expiry in RFC3339 format.

We want to migrate to `expires_on` when the underlying az cli supports
it and fallback to the existing `expiresOn` otherwise.


### Provide a list of related PRs _(if any)_

Azure/azure-sdk-for-net#41366
Azure/azure-sdk-for-cpp#5075
@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Projects
Development

Successfully merging a pull request may close this issue.

3 participants