auth: Fix appending .default
to tenant id scope
#1608
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1607
Bug background
These two PRs sorta worked together to introduce this bug. The first started adding
.default
to the scopes, and the second made it so the scopes are passed through that method twice. Meaning that.default
is added to theVSCODE_TENANT
the second time the scopes are passed into that method.authentication.getSession
use scopes argument #1597The resulting set of scopes will have:
["VSCODE_TENANT:<tenant id>", "VSCODE_TENANT:<tenant id>.default"]
. The second entry shouldn't exist and it messes up the built-in authentication provider sometimes since it's not a valid tenant id.Solution
The changes I've made make it so that we only call
vscode.authentication.getSession
in one place. And in that one place is where the scope list is constructed. This avoids any mistakes regarding building the scope list twice.getSessionFromVSCode
helper, which wrapsvscode.authentication.getSession
and handles constructing the scope list, and adding theVSCODE_TENANT
scope.VSCodeAzureSubscriptionProvider
do not need to handle scope list creation, they just pass along the tenant id and resource scopes.