mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Add support for other vscode environments for github auth
This commit is contained in:
parent
94b4d22c33
commit
bf0a32e729
|
@ -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
|
||||
|
|
|
@ -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 = {};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue