From 39c6779828ffd46db840b6f0d6d1fc9e5156207c Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Mon, 21 Mar 2022 09:35:34 -0700 Subject: [PATCH] depend on stable vscode.dev for auth extensions --- extensions/github-authentication/src/githubServer.ts | 11 ++++++++--- extensions/microsoft-authentication/src/AADHelper.ts | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/extensions/github-authentication/src/githubServer.ts b/extensions/github-authentication/src/githubServer.ts index 439089503ca..6de1daf7f62 100644 --- a/extensions/github-authentication/src/githubServer.ts +++ b/extensions/github-authentication/src/githubServer.ts @@ -17,10 +17,12 @@ const localize = nls.loadMessageBundle(); const CLIENT_ID = '01ab8ac9400c4e429b23'; const GITHUB_AUTHORIZE_URL = 'https://github.com/login/oauth/authorize'; // TODO: change to stable when that happens -const GITHUB_TOKEN_URL = 'https://insiders.vscode.dev/codeExchangeProxyEndpoints/github/login/oauth/access_token'; -const REDIRECT_URL = 'https://insiders.vscode.dev/redirect'; +const GITHUB_TOKEN_URL = 'https://vscode.dev/codeExchangeProxyEndpoints/github/login/oauth/access_token'; const NETWORK_ERROR = 'network error'; +const REDIRECT_URL_STABLE = 'https://vscode.dev/redirect'; +const REDIRECT_URL_INSIDERS = 'https://insiders.vscode.dev/redirect'; + class UriEventHandler extends vscode.EventEmitter implements vscode.UriHandler { constructor(private readonly Logger: Log) { super(); @@ -163,9 +165,12 @@ export class GitHubServer implements IGitHubServer { const existingNonces = this._pendingNonces.get(scopes) || []; this._pendingNonces.set(scopes, [...existingNonces, nonce]); + const proxyEndpoints: { [providerId: string]: string } | undefined = await vscode.commands.executeCommand('workbench.getCodeExchangeProxyEndpoints'); + // If we are running in insiders vscode.dev, then ensure we use the redirect route on that. + const redirectUri = proxyEndpoints?.github?.includes('https://insiders.vscode.dev') ? REDIRECT_URL_INSIDERS : REDIRECT_URL_STABLE; const searchParams = new URLSearchParams([ ['client_id', CLIENT_ID], - ['redirect_uri', REDIRECT_URL], + ['redirect_uri', redirectUri], ['scope', scopes], ['state', encodeURIComponent(callbackUri.toString(true))] ]); diff --git a/extensions/microsoft-authentication/src/AADHelper.ts b/extensions/microsoft-authentication/src/AADHelper.ts index 736106853fa..8321b5682be 100644 --- a/extensions/microsoft-authentication/src/AADHelper.ts +++ b/extensions/microsoft-authentication/src/AADHelper.ts @@ -20,8 +20,7 @@ import path = require('path'); const localize = nls.loadMessageBundle(); -// TODO: Change to stable when it's deployed. -const redirectUrl = 'https://insiders.vscode.dev/redirect'; +const redirectUrl = 'https://vscode.dev/redirect'; const loginEndpointUrl = 'https://login.microsoftonline.com/'; const DEFAULT_CLIENT_ID = 'aebc6443-996d-45c2-90f0-388ff96faa56'; const DEFAULT_TENANT = 'organizations';