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

auth: Fix appending .default to tenant id scope #1608

Merged
merged 3 commits into from
Oct 19, 2023

Conversation

alexweininger
Copy link
Member

@alexweininger alexweininger commented Oct 19, 2023

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 the VSCODE_TENANT the second time the scopes are passed into that method.

The 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.

  • Add getSessionFromVSCode helper, which wraps vscode.authentication.getSession and handles constructing the scope list, and adding the VSCODE_TENANT scope.
  • Code inside VSCodeAzureSubscriptionProvider do not need to handle scope list creation, they just pass along the tenant id and resource scopes.

@alexweininger alexweininger requested a review from a team as a code owner October 19, 2023 20:04
@alexweininger alexweininger changed the title Alex/harlequin ladybug Fix appending .default to tenant id scope Oct 19, 2023
@alexweininger alexweininger merged commit 9931452 into main Oct 19, 2023
4 checks passed
@alexweininger alexweininger deleted the alex/harlequin-ladybug branch October 19, 2023 20:14
@alexweininger alexweininger changed the title Fix appending .default to tenant id scope auth: Fix appending .default to tenant id scope Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.default is mistakenly appended to VSCODE_TENANT scope, which can break sign in
2 participants