From f1a5d40aa756f3406f2f6680d9d735d92c0d6eb6 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Wed, 26 May 2021 11:54:15 -0700 Subject: [PATCH] refactor getCallbackEnvironment to return authority by default --- .../microsoft-authentication/src/AADHelper.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/microsoft-authentication/src/AADHelper.ts b/extensions/microsoft-authentication/src/AADHelper.ts index 2414055c282..5fe6aeaae05 100644 --- a/extensions/microsoft-authentication/src/AADHelper.ts +++ b/extensions/microsoft-authentication/src/AADHelper.ts @@ -396,19 +396,19 @@ export class AzureActiveDirectoryService { } private getCallbackEnvironment(callbackUri: vscode.Uri): string { - if (callbackUri.authority.endsWith('.workspaces.github.com') || callbackUri.authority.endsWith('.github.dev')) { - return `${callbackUri.authority},`; + if (callbackUri.scheme !== 'https' && callbackUri.scheme !== 'http') { + return callbackUri.scheme; } switch (callbackUri.authority) { case 'online.visualstudio.com': - return 'vso,'; + return 'vso'; case 'online-ppe.core.vsengsaas.visualstudio.com': - return 'vsoppe,'; + return 'vsoppe'; case 'online.dev.core.vsengsaas.visualstudio.com': - return 'vsodev,'; + return 'vsodev'; default: - return `${callbackUri.scheme},`; + return callbackUri.authority; } } @@ -417,7 +417,7 @@ export class AzureActiveDirectoryService { const nonce = randomBytes(16).toString('base64'); const port = (callbackUri.authority.match(/:([0-9]*)$/) || [])[1] || (callbackUri.scheme === 'https' ? 443 : 80); const callbackEnvironment = this.getCallbackEnvironment(callbackUri); - const state = `${callbackEnvironment}${port},${encodeURIComponent(nonce)},${encodeURIComponent(callbackUri.query)}`; + const state = `${callbackEnvironment},${port},${encodeURIComponent(nonce)},${encodeURIComponent(callbackUri.query)}`; const signInUrl = `${loginEndpointUrl}${tenant}/oauth2/v2.0/authorize`; let uri = vscode.Uri.parse(signInUrl); const codeVerifier = toBase64UrlEncoding(randomBytes(32).toString('base64'));