Repository navigation
Remove dependency on Azure Account extension - #551
Conversation
There was a problem hiding this comment.
Thanks heaps and looks good to me, lets get more eyes for testing and Hariharan Subramanian (@hsubramanianaks) eyes as well as he was keen to monitor these changes as well. + Prabhakaran S (@sprab) and Quentin Petraroia (@qpetraroia) for testing help please β€οΈβ€οΈβοΈ (Might be testing from non-msft account as well)
- Question: Given the nature of this PR - do we want to release this separately as lighter but kind of breaking drop , as this will need re-signin from all users who are suing this extension?
This definitely seems progressive PR.
|
Hariharan Subramanian (@hsubramanianaks) found a bug where the following happens:
In that case VS Code thinks you're still signing in (there's no way it can be notified you've closed the browser tab). And if you try to sign in again, it waits for the original sign-in request to complete. This behaviour is part of the VS Code API and beyond our control. It is documented as a feature request in the VS Code repo, with the request being to support cancellation. The discussion suggests the request will eventually time out, but that did not happen for me after several minutes and I got tired of waiting. The issue has been in its current state for 3 years, so it doesn't look as if it'll see any movement anytime soon. If it were to be fixed (i.e. the API changed to support cancellation) we could present a popup similar to the Azure Account one: As it is, I'm reluctant to make further changes at this stage, for what I hope is a relatively infrequent scenario. One thing we could do is display a cancellation dialog (like the one above), and if the user cancels we invoke the 'reload window' command. It's a bit of a sledgehammer approach, but it's currently the only way I can see for the user to get out of the trap. I think it'd make sense to try something like this in a separate PR, so it's easier to roll it back and replace with a better solution if we think of something. Any thoughts, Hariharan Subramanian (@hsubramanianaks) and Tatsat (Tats) Mishra π (@Tatsinnit)? |
77edfd2
1cbbdb6 to
6705c58
Compare
Tatsat (Tats) Mishra π (Tatsinnit)
left a comment
There was a problem hiding this comment.
Looks good to me, more unbiased test will be if Hariharan Subramanian (@hsubramanianaks) can please share his testing or anyone else who kindly help for testing, thanks heaps for hits.
|
Testing checklist:
|
2234c95
cc940a5 to
4960883
Compare
Things moved fast in last 8 hours, want to make sure I am merging this PR out of too much zeal. Thanks
|
If you want to pursue using the package, my suggestion is that we meet to go over your requirements in more detail to see if it's the right fit. |
|
Alex Weininger (@alexweininger), Tatsat (Tats) Mishra π (@Tatsinnit), Hariharan Subramanian (@hsubramanianaks) - thank you all for the comments. I'd really like to work on a shared implementation for the authentication library, which I'm keen to devote some careful thought to and work with Alex Weininger (@alexweininger) on building. I think this will take some time and should not be rushed. The core changes here are centralised in a couple of files, with the implementations abstracted away behind interfaces. I think that gives us a path forward:
There is no need for these later changes to have any impact on UX. The wrapper code uses the same underlying VS Code API, so user sessions should remain intact if we swap out implementations. The wrapper also supports custom subscription filters so we can continue to use the same user settings introduced in this PR. |
|
+1 to peterbom's vision here and thank you Alex Weininger (@alexweininger) for being open to meeting us and discussing our requirements! |
|
Signing off. I have opened a bug on our side to alert customers of the current issues with Azure login and the appropriate steps on how to fix it #639. |
β¦the change, and get session silently whenever possible
β¦ with interface
68dc1a1
1b8d589 to
68dc1a1
Compare
* Use vscode authentication library instead of Azure Account extension * remove msal-node dependency * remove azure auth * remove duplication of getDefaultScope function and add error handling * auth fixes for switching between signed-in tenants * If no subscriptions are selected, display them all in the treeview * remove unused properties from jwt interface * fix URLs in select-subscriptions command * get tenant id from auth session and new filter option for listing subs * avoid passing treenodes to cluster library functions * avoid exposing ISubscriptionContext from tree nodes * handle session changes when tenants change and not when we triggered the change, and get session silently whenever possible * Select a tenant by default rather than forcing user to do that * list clusters using resource management client (as we were before) * dedicated command for tenant selection, and abstract session provider with interface



Addresses #566
This removes our dependence on the deprecated Azure Account extension.
The following commands were originally only in the Azure Account extension, and so have been re-implemented in the AKS extension:
This required a new configuration setting in the AKS extension:
aks.selectedSubscriptions. This behaves identically to the equivalent setting in the Azure Account extension (azure.resourceFilter). If the Azure Account setting exists, our extension will still use that, until the selected subscriptions for the AKS extension are changed.The recommended alternative to the Azure Account extension is the @microsoft/vscode-azext-azureauth package. However, this does not provide good support for getting credentials that we can use to create clients for other Azure SDKs. It was necessary to use the VS Code authentication API directly, in addition to the Azure Auth API. This duplication made the session state confusing and potentially inconsistent. To simplify, I removed the dependency on the Azure Authentication package in favour of consuming just the VS Code API (see
azureAuth.ts).Until now we have also been using the @microsoft/vscode-azext-azureutils package which provides base class implementations of Account and Subscription nodes for our Cloud Explorer treeview. Unfortunately these classes are very tightly coupled to the Azure Account extension. Since our code base makes heavy use of credentials retrieved from tree nodes (via
ISubscriptionContext), using these base classes means we are still using the Azure Account extension. So, this PR removes that package dependency too, and now implements the Account and Subscription tree nodes directly (based on classes in the @microsoft/vscode-azext-utils library, which is not tied to the Azure Account extension). This change means the Account and Subscription icons are now in our own repository, and so the webpack configuration for copying these files has also been removed.For AAD clusters, we were previously using the low-level MSAL library to get an access token using the cluster's tenant and server scopes. This made use of a refresh token retrieved from the
ISubscriptionContextcredentials. With the authentication changes, this is now no longer available. Besides, the refresh token flow was not recommended anyway. Fortunately, the VS Code authentication API handles this scenario, without us having to resort to lower-level libraries, and so that dependency is also removed.Other notes:
clusters.tscontains functions for creating ARM clients for other resource types (not just clusters). I'd like to move these to the newarm.tsfile so they're in one place, and so it's easier to verify that we're using credentials in a consistent manner. We can do that in a separate PR.clusters.ts, I createdsubscriptions.ts. I think we can follow a similar pattern of having separate files for other ARM resources.azureAccount.tsfile needs more work. It was previously used to get the Azure Account extension API, plus some miscellaneous ASO functionality (which is now broken on the MS tenant, see Install ASO command fails on some tenantsΒ #552). As part of fixing the ASO functionality, we should probably delete this file entirely.