You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(2) this code was broken. Fix is in main but not released yet
Current state:
sequenceDiagram
autonumber
participant User
participant Extension
participant ADO_API
participant CLI
User->>Extension: run command
Extension->>CLI: get subscriptions
CLI-->>Extension:
%%Extension->>Extension:
%%activate Extension
loop Validation: subscription/user pairs to find working token
Extension->>CLI: Get token for sub/user
CLI-->Extension:
Extension->>ADO_API: Try fetching data with token
alt failure
ADO_API-->>Extension: fail
Note over ADO_API,Extension: continue loop
else success
ADO_API-->>Extension: success
Note over ADO_API,Extension: exit loop
end
opt After loop exhaustion
Extension-->>User: Display AAD token error
end
opt After successfull token validation
Extension->>ADO_API: Fetch data
ADO_API-->>Extension:
Extension-->>User: Display for ADO API request
end
end
Note right of ADO_API: slow and unneeded loop
Loading
Future?:
sequenceDiagram
autonumber
participant User
participant Extension
participant ADO_API
participant CLI
User->>Extension: run command
Extension->>ADO_API: get data from protected enpoint
ADO_API-->>Extension:
Extension->>CLI: get subscriptions
CLI-->>Extension:
Extension->Extension: find correct subscription/username pair for given tenant id
Extension->>CLI: Get token for sub/user
CLI-->Extension:
Extension->Extension: handle profile.get_raw_token() errors
opt After getting token for given tenant
Note over ADO_API,Extension: validation not really needed
Extension->>ADO_API: Fetch data
ADO_API-->>Extension:
Extension-->>User: Display for ADO API request
end
opt Token not found or other profile.get_raw_token() exception
Extension-->>User: Display AAD token error
end
Is your feature request related to a problem? Please describe.
AAD token authentication is really flaky, hides error messages and has terrible UX
Splitted from issue #1258
Describe the solution you'd like
Rewrite most of the related code
Background Story
Current status
subscriptions = profile.load_cached_subscriptions(False)loops through the informationtoken = get_token_from_az_login(profile, key[0])validate_token_for_instance(organization, credentials)get_token_from_az_logins()and_get_credentials()will raise exceptionvalidate_token_for_instance()is described laterget_token_from_az_login() problems
azure-devops-cli-extension/azure-devops/azext_devops/dev/common/services.py
Lines 155 to 165 in b3d0392
profile.get_raw_token()are masked by logger.debug()validate_token_for_instance() problems
azure-devops-cli-extension/azure-devops/azext_devops/dev/common/services.py
Lines 86 to 98 in b3d0392
get_token_from_az_logins() problem
azure-devops-cli-extension/azure-devops/azext_devops/dev/common/services.py
Lines 116 to 152 in b3d0392
Issues
--debug--tenant,--allow-no-subscriptionsand maybe even give hint about active subscription selectionProposed fixes
Add
--tenantparameterIf user can applies tenant id then
azure-devops-cli-extension/azure-devops/azext_devops/dev/common/services.py
Lines 123 to 128 in b3d0392
logic of that code could be simplified and looping all available tenants is not needed
Request tenant id from Azure Devops service
ADO API returns tenant id with 403 replies
The following headers are returned from ADO:
Looping through all tenant information is not needed if tenant information is fetch from the ADO API.
Removal of token validation
Removal of the tenant loops
(1)
azure-devops-cli-extension/azure-devops/azext_devops/dev/common/services.py
Line 119 in b3d0392
(2) this code was broken. Fix is in main but not released yet
Current state:
sequenceDiagram autonumber participant User participant Extension participant ADO_API participant CLI User->>Extension: run command Extension->>CLI: get subscriptions CLI-->>Extension: %%Extension->>Extension: %%activate Extension loop Validation: subscription/user pairs to find working token Extension->>CLI: Get token for sub/user CLI-->Extension: Extension->>ADO_API: Try fetching data with token alt failure ADO_API-->>Extension: fail Note over ADO_API,Extension: continue loop else success ADO_API-->>Extension: success Note over ADO_API,Extension: exit loop end opt After loop exhaustion Extension-->>User: Display AAD token error end opt After successfull token validation Extension->>ADO_API: Fetch data ADO_API-->>Extension: Extension-->>User: Display for ADO API request end end Note right of ADO_API: slow and unneeded loopFuture?:
sequenceDiagram autonumber participant User participant Extension participant ADO_API participant CLI User->>Extension: run command Extension->>ADO_API: get data from protected enpoint ADO_API-->>Extension: Extension->>CLI: get subscriptions CLI-->>Extension: Extension->Extension: find correct subscription/username pair for given tenant id Extension->>CLI: Get token for sub/user CLI-->Extension: Extension->Extension: handle profile.get_raw_token() errors opt After getting token for given tenant Note over ADO_API,Extension: validation not really needed Extension->>ADO_API: Fetch data ADO_API-->>Extension: Extension-->>User: Display for ADO API request end opt Token not found or other profile.get_raw_token() exception Extension-->>User: Display AAD token error end