diff --git a/build/azure-pipelines/product-compile.yml b/build/azure-pipelines/product-compile.yml index 58611074190..48916189326 100644 --- a/build/azure-pipelines/product-compile.yml +++ b/build/azure-pipelines/product-compile.yml @@ -82,6 +82,16 @@ steps: OSS_GITHUB_SECRET: $(oss-github-client-secret) INSIDERS_GITHUB_ID: "31f02627809389d9f111" INSIDERS_GITHUB_SECRET: $(insiders-github-client-secret) + STABLE_GITHUB_ID: "baa8a44b5e861d918709" + STABLE_GITHUB_SECRET: $(stable-github-client-secret) + EXPLORATION_GITHUB_ID: "94e8376d3a90429aeaea" + EXPLORATION_GITHUB_SECRET: $(exploration-github-client-secret) + VSO_GITHUB_ID: "3d4be8f37a0325b5817d" + VSO_GITHUB_SECRET: $(vso-github-client-secret) + VSO_PPE_GITHUB_ID: "eabf35024dc2e891a492" + VSO_PPE_GITHUB_SECRET: $(vso-ppe-github-client-secret) + VSO_DEV_GITHUB_ID: "84383ebd8a7c5f5efc5c" + VSO_DEV_GITHUB_SECRET: $(vso-dev-github-client-secret) # Mixin must run before optimize, because the CSS loader will # inline small SVGs diff --git a/extensions/github-authentication/build/postinstall.js b/extensions/github-authentication/build/postinstall.js index 23228f45e8a..e12fd05f191 100644 --- a/extensions/github-authentication/build/postinstall.js +++ b/extensions/github-authentication/build/postinstall.js @@ -6,7 +6,7 @@ const fs = require('fs'); const path = require('path'); -const schemes = ['OSS', 'INSIDERS']; +const schemes = ['OSS', 'INSIDERS', 'STABLE', 'EXPLORATION', 'VSO', 'VSO_PPE', 'VSO_DEV']; function main() { let content = {}; diff --git a/extensions/github-authentication/src/common/clientRegistrar.ts b/extensions/github-authentication/src/common/clientRegistrar.ts index b4de0b8138a..c16c7221ff2 100644 --- a/extensions/github-authentication/src/common/clientRegistrar.ts +++ b/extensions/github-authentication/src/common/clientRegistrar.ts @@ -3,6 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { Uri } from 'vscode'; + export interface ClientDetails { id?: string; secret?: string; @@ -11,6 +13,12 @@ export interface ClientDetails { export interface ClientConfig { OSS: ClientDetails; INSIDERS: ClientDetails; + STABLE: ClientDetails; + EXPLORATION: ClientDetails; + + VSO: ClientDetails; + VSO_PPE: ClientDetails; + VSO_DEV: ClientDetails; } export class Registrar { @@ -22,13 +30,18 @@ export class Registrar { } catch (e) { this._config = { OSS: {}, - INSIDERS: {} + INSIDERS: {}, + STABLE: {}, + EXPLORATION: {}, + VSO: {}, + VSO_PPE: {}, + VSO_DEV: {} }; } } - getClientDetails(product: string): ClientDetails { + getClientDetails(callbackUri: Uri): ClientDetails { let details: ClientDetails | undefined; - switch (product) { + switch (callbackUri.scheme) { case 'code-oss': details = this._config.OSS; break; @@ -37,12 +50,33 @@ export class Registrar { details = this._config.INSIDERS; break; + case 'vscode': + details = this._config.STABLE; + break; + + case 'vscode-exploration': + details = this._config.EXPLORATION; + break; + + case 'https': + switch (callbackUri.authority) { + case 'online.visualstudio.com': + details = this._config.VSO; + break; + case 'online-ppe.core.vsengsaas.visualstudio.com': + details = this._config.VSO_PPE; + break; + case 'online.dev.core.vsengsaas.visualstudio.com': + details = this._config.VSO_DEV; + break; + } + default: - throw new Error(`Unrecognized product ${product}`); + throw new Error(`Unrecognized callback ${callbackUri}`); } if (!details.id || !details.secret) { - throw new Error(`No client configuration available for ${product}`); + throw new Error(`No client configuration available for ${callbackUri}`); } return details; diff --git a/extensions/github-authentication/src/githubServer.ts b/extensions/github-authentication/src/githubServer.ts index 6c84738261d..336a27b2392 100644 --- a/extensions/github-authentication/src/githubServer.ts +++ b/extensions/github-authentication/src/githubServer.ts @@ -71,7 +71,7 @@ export class GitHubServer { Logger.info('Logging in...'); const state = uuid(); const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://vscode.github-authentication/did-authenticate`)); - const clientDetails = ClientRegistrar.getClientDetails(callbackUri.scheme); + const clientDetails = ClientRegistrar.getClientDetails(callbackUri); const uri = vscode.Uri.parse(`https://github.com/login/oauth/authorize?redirect_uri=${encodeURIComponent(callbackUri.toString())}&scope=${scopes}&state=${state}&client_id=${clientDetails.id}`); vscode.env.openExternal(uri);