Azure / azure-sdk-for-rust

This repository is for active development of the *unofficial* Azure SDK for Rust. This repository is *not* supported by the Azure SDK team.
MIT License
692 stars 237 forks source link

implement `az version` check in `AzureCliCredential::create` #1533

Open cataggar opened 8 months ago

cataggar commented 8 months ago

This is a follow up to #1532 to check az version in the AzureCliCredential::create function.

The version check could also be used in combination with a feature to determine if the expires_on can be used instead of expireOn. It was fixed in Azure CLI 2.54.0 https://github.com/Azure/azure-cli/pull/27476#issuecomment-1835432354.

cataggar commented 8 months ago
~/ms/azure-sdk-for-rust> az version --output json
{
  "azure-cli": "2.54.0",
  "azure-cli-core": "2.54.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {
    "vmware": "5.0.2"
  }
}
~/ms/azure-sdk-for-rust> az account get-access-token --output json
{
  "accessToken": "MuchLonger_NotTheRealOne_Sv8Orn0Wq0OaXuQEg",
  "expiresOn": "2024-01-01 19:23:16.000000",
  "expires_on": 1704158596,
  "subscription": "33b83be5-faf7-42ea-a712-320a5f9dd111",
  "tenant": "065e9f5e-870d-4ed1-af2b-1b58092353f3",
  "tokenType": "Bearer"
}
demoray commented 8 months ago

Instead of parsing the az-cli version, can we just check if expires_on exists and use that, otherwise use expiresOn?

Based on the az-cli PR linked above, this looks potentially feasible.