Skip to content

Commit bf0a32e

Browse files
author
Rachel Macfarlane
committed
Add support for other vscode environments for github auth
1 parent 94b4d22 commit bf0a32e

4 files changed

Lines changed: 51 additions & 7 deletions

File tree

build/azure-pipelines/product-compile.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ steps:
8282
OSS_GITHUB_SECRET: $(oss-github-client-secret)
8383
INSIDERS_GITHUB_ID: "31f02627809389d9f111"
8484
INSIDERS_GITHUB_SECRET: $(insiders-github-client-secret)
85+
STABLE_GITHUB_ID: "baa8a44b5e861d918709"
86+
STABLE_GITHUB_SECRET: $(stable-github-client-secret)
87+
EXPLORATION_GITHUB_ID: "94e8376d3a90429aeaea"
88+
EXPLORATION_GITHUB_SECRET: $(exploration-github-client-secret)
89+
VSO_GITHUB_ID: "3d4be8f37a0325b5817d"
90+
VSO_GITHUB_SECRET: $(vso-github-client-secret)
91+
VSO_PPE_GITHUB_ID: "eabf35024dc2e891a492"
92+
VSO_PPE_GITHUB_SECRET: $(vso-ppe-github-client-secret)
93+
VSO_DEV_GITHUB_ID: "84383ebd8a7c5f5efc5c"
94+
VSO_DEV_GITHUB_SECRET: $(vso-dev-github-client-secret)
8595

8696
# Mixin must run before optimize, because the CSS loader will
8797
# inline small SVGs

extensions/github-authentication/build/postinstall.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const fs = require('fs');
77
const path = require('path');
88

9-
const schemes = ['OSS', 'INSIDERS'];
9+
const schemes = ['OSS', 'INSIDERS', 'STABLE', 'EXPLORATION', 'VSO', 'VSO_PPE', 'VSO_DEV'];
1010

1111
function main() {
1212
let content = {};

extensions/github-authentication/src/common/clientRegistrar.ts

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { Uri } from 'vscode';
7+
68
export interface ClientDetails {
79
id?: string;
810
secret?: string;
@@ -11,6 +13,12 @@ export interface ClientDetails {
1113
export interface ClientConfig {
1214
OSS: ClientDetails;
1315
INSIDERS: ClientDetails;
16+
STABLE: ClientDetails;
17+
EXPLORATION: ClientDetails;
18+
19+
VSO: ClientDetails;
20+
VSO_PPE: ClientDetails;
21+
VSO_DEV: ClientDetails;
1422
}
1523

1624
export class Registrar {
@@ -22,13 +30,18 @@ export class Registrar {
2230
} catch (e) {
2331
this._config = {
2432
OSS: {},
25-
INSIDERS: {}
33+
INSIDERS: {},
34+
STABLE: {},
35+
EXPLORATION: {},
36+
VSO: {},
37+
VSO_PPE: {},
38+
VSO_DEV: {}
2639
};
2740
}
2841
}
29-
getClientDetails(product: string): ClientDetails {
42+
getClientDetails(callbackUri: Uri): ClientDetails {
3043
let details: ClientDetails | undefined;
31-
switch (product) {
44+
switch (callbackUri.scheme) {
3245
case 'code-oss':
3346
details = this._config.OSS;
3447
break;
@@ -37,12 +50,33 @@ export class Registrar {
3750
details = this._config.INSIDERS;
3851
break;
3952

53+
case 'vscode':
54+
details = this._config.STABLE;
55+
break;
56+
57+
case 'vscode-exploration':
58+
details = this._config.EXPLORATION;
59+
break;
60+
61+
case 'https':
62+
switch (callbackUri.authority) {
63+
case 'online.visualstudio.com':
64+
details = this._config.VSO;
65+
break;
66+
case 'online-ppe.core.vsengsaas.visualstudio.com':
67+
details = this._config.VSO_PPE;
68+
break;
69+
case 'online.dev.core.vsengsaas.visualstudio.com':
70+
details = this._config.VSO_DEV;
71+
break;
72+
}
73+
4074
default:
41-
throw new Error(`Unrecognized product ${product}`);
75+
throw new Error(`Unrecognized callback ${callbackUri}`);
4276
}
4377

4478
if (!details.id || !details.secret) {
45-
throw new Error(`No client configuration available for ${product}`);
79+
throw new Error(`No client configuration available for ${callbackUri}`);
4680
}
4781

4882
return details;

extensions/github-authentication/src/githubServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class GitHubServer {
7171
Logger.info('Logging in...');
7272
const state = uuid();
7373
const callbackUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://vscode.github-authentication/did-authenticate`));
74-
const clientDetails = ClientRegistrar.getClientDetails(callbackUri.scheme);
74+
const clientDetails = ClientRegistrar.getClientDetails(callbackUri);
7575
const uri = vscode.Uri.parse(`https://github.com/login/oauth/authorize?redirect_uri=${encodeURIComponent(callbackUri.toString())}&scope=${scopes}&state=${state}&client_id=${clientDetails.id}`);
7676

7777
vscode.env.openExternal(uri);

0 commit comments

Comments
 (0)