Skip to content

Commit

Permalink
Ignore .default if it is passed as a scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft committed Jul 21, 2023
1 parent c274510 commit 906252e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions auth/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@microsoft/vscode-azext-azureauth",
"author": "Microsoft Corporation",
"version": "1.1.0",
"version": "1.1.1",
"description": "Azure authentication helpers for Visual Studio Code",
"tags": [
"azure",
Expand Down
7 changes: 4 additions & 3 deletions auth/src/VSCodeAzureSubscriptionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export class VSCodeAzureSubscriptionProvider extends vscode.Disposable implement

const credential: TokenCredential = {
getToken: async (scopes) => {
// TODO: change to `getSessions` when that API is available: https://github.com/microsoft/vscode/issues/152399
// TODO: if possible, change to `getSessions` when that API is available: https://github.com/microsoft/vscode/issues/152399
session = await vscode.authentication.getSession(getConfiguredAuthProviderId(), this.getScopes(scopes, tenantId), { createIfNone: false, silent: true });
if (!session) {
throw new NotSignedInError();
Expand Down Expand Up @@ -266,10 +266,11 @@ export class VSCodeAzureSubscriptionProvider extends vscode.Disposable implement
private getScopes(scopes: string | string[] | undefined, tenantId?: string): string[] {
const scopeSet = new Set<string>(this.getDefaultScopes());

if (typeof scopes === 'string') {
// If `.default` is passed in, it will be ignored, in favor of the correct default added by `getDefaultScopes`
if (typeof scopes === 'string' && scopes !== '.default') {
scopeSet.add(scopes);
} else if (Array.isArray(scopes)) {
scopes.forEach(scope => scopeSet.add(scope));
scopes.filter(scope => scope !== '.default').forEach(scope => scopeSet.add(scope));
}

if (tenantId) {
Expand Down

0 comments on commit 906252e

Please sign in to comment.