Revert "Use MSAL library for auth in web for settings sync"

This reverts commit 122a598f5a.
This commit is contained in:
Rachel Macfarlane 2019-11-15 16:02:00 -08:00
parent 6e868d0905
commit 0ed22e31c6
10 changed files with 10 additions and 90 deletions

View file

@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.41.0",
"distro": "e3f0dacfbf82a87e6a3e826d18282d02a67c25c7",
"distro": "403ab44be562c63a0cde1969fd8f5b45ff51709c",
"author": {
"name": "Microsoft Corporation"
},
@ -38,7 +38,6 @@
"iconv-lite": "0.5.0",
"jschardet": "2.1.1",
"keytar": "^4.11.0",
"msal": "^1.1.3",
"native-is-elevated": "0.4.1",
"native-keymap": "2.0.0",
"native-watchdog": "1.2.0",

View file

@ -10,7 +10,6 @@
"https-proxy-agent": "^2.2.3",
"iconv-lite": "0.5.0",
"jschardet": "2.1.1",
"msal": "^1.1.3",
"native-watchdog": "1.2.0",
"node-pty": "^0.10.0-beta2",
"onigasm-umd": "^2.2.4",

View file

@ -2,7 +2,6 @@
"name": "vscode-web",
"version": "0.0.0",
"dependencies": {
"msal": "^1.1.3",
"onigasm-umd": "^2.2.4",
"semver-umd": "^5.5.3",
"vscode-textmate": "^4.3.0",

View file

@ -2,13 +2,6 @@
# yarn lockfile v1
msal@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/msal/-/msal-1.1.3.tgz#d8c501d513f5e52eaf000f20a245526fc1ecaa2a"
integrity sha512-cdShb+N1H3OyR1y46ij6OO7QzeqC6BxrbrNcouS4JBrr1+DnZ55TumxQKEzWmTXHvsbsuz5PCyXZl812Un8L9g==
dependencies:
tslib "^1.9.3"
nan@^2.14.0:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
@ -31,11 +24,6 @@ semver-umd@^5.5.3:
resolved "https://registry.yarnpkg.com/semver-umd/-/semver-umd-5.5.3.tgz#b64d7a2d4f5a717b369d56e31940a38e47e34d1e"
integrity sha512-HOnQrn2iKnVe/xlqCTzMXQdvSz3rPbD0DmQXYuQ+oK1dpptGFfPghonQrx5JHl2O7EJwDqtQnjhE7ME23q6ngw==
tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
vscode-textmate@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-4.3.0.tgz#6e1f0f273d84148cfa1e9c7ed85bd16c974f9f61"

View file

@ -256,13 +256,6 @@ ms@2.0.0:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
msal@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/msal/-/msal-1.1.3.tgz#d8c501d513f5e52eaf000f20a245526fc1ecaa2a"
integrity sha512-cdShb+N1H3OyR1y46ij6OO7QzeqC6BxrbrNcouS4JBrr1+DnZ55TumxQKEzWmTXHvsbsuz5PCyXZl812Un8L9g==
dependencies:
tslib "^1.9.3"
nan@^2.10.0, nan@^2.14.0:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
@ -371,11 +364,6 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"
tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
universalify@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"

View file

@ -33,7 +33,6 @@
'xterm-addon-search': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
'xterm-addon-web-links': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
'semver-umd': `${window.location.origin}/static/remote/web/node_modules/semver-umd/lib/semver-umd.js`,
'Msal': `${window.location.origin}/static/node_modules/msal/dist/msal.min.js`,
}
};
</script>

View file

@ -37,7 +37,6 @@
'xterm-addon-search': `${window.location.origin}/static/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
'xterm-addon-web-links': `${window.location.origin}/static/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
'semver-umd': `${window.location.origin}/static/node_modules/semver-umd/lib/semver-umd.js`,
'Msal': `${window.location.origin}/static/node_modules/msal/dist/msal.min.js`,
}
};
</script>

View file

@ -8,15 +8,11 @@ import { Event, Emitter } from 'vs/base/common/event';
import { IAuthTokenService, AuthTokenStatus } from 'vs/platform/auth/common/auth';
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
import { Disposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { UserAgentApplication } from 'Msal';
import { URI } from 'vs/base/common/uri';
const SERVICE_NAME = 'VS Code';
const ACCOUNT = 'MyAccount';
const clientId = 'aebc6443-996d-45c2-90f0-388ff96faa56';
export class AuthTokenService extends Disposable implements IAuthTokenService {
_serviceBrand: undefined;
@ -28,25 +24,15 @@ export class AuthTokenService extends Disposable implements IAuthTokenService {
readonly _onDidGetCallback: Emitter<URI> = this._register(new Emitter<URI>());
private _msalInstance: UserAgentApplication | undefined;
private _loadMsal: Promise<void>;
constructor(
@ICredentialsService private readonly credentialsService: ICredentialsService,
@IEnvironmentService private readonly environmentService: IEnvironmentService,
@IQuickInputService private readonly quickInputService: IQuickInputService,
@INotificationService private readonly notificationService: INotificationService
@IQuickInputService private readonly quickInputService: IQuickInputService
) {
super();
this._loadMsal = (import('Msal')).then(msal => {
this._msalInstance = new msal.UserAgentApplication({ auth: { clientId } });
});
this._status = AuthTokenStatus.Inactive;
this.getToken().then(token => {
if (token) {
this.setStatus(AuthTokenStatus.Active);
} else {
this.setStatus(AuthTokenStatus.Inactive);
}
});
}
@ -55,40 +41,16 @@ export class AuthTokenService extends Disposable implements IAuthTokenService {
const token = await this.credentialsService.getPassword(SERVICE_NAME, ACCOUNT);
if (token) {
return token;
} else {
if (!this.environmentService.isBuilt) {
return;
}
try {
await this._loadMsal;
const response = await this._msalInstance!.acquireTokenSilent({});
return response.accessToken;
} catch (e) {
return;
}
}
return;
}
async login(): Promise<void> {
// Cannot redirect to localhost in the implicit grant flow, fall back to asking for token when running out of sources
if (!this.environmentService.isBuilt) {
const token = await this.quickInputService.input({ placeHolder: localize('enter token', "Please provide the auth bearer token"), ignoreFocusLost: true, });
if (token) {
await this.credentialsService.setPassword(SERVICE_NAME, ACCOUNT, token);
this.setStatus(AuthTokenStatus.Active);
}
return;
}
try {
await this._loadMsal;
const response = await this._msalInstance!.loginPopup();
await this.credentialsService.setPassword(SERVICE_NAME, ACCOUNT, response.accessToken);
const token = await this.quickInputService.input({ placeHolder: localize('enter token', "Please provide the auth bearer token"), ignoreFocusLost: true, });
if (token) {
await this.credentialsService.setPassword(SERVICE_NAME, ACCOUNT, token);
this.setStatus(AuthTokenStatus.Active);
} catch (e) {
this.notificationService.error(localize('loginFailed', "Login failed: {0}", e));
}
}

View file

@ -472,8 +472,7 @@
"**/vs/workbench/api/{common,browser}/**",
"**/vs/workbench/services/**/{common,browser}/**",
"vscode-textmate",
"onigasm-umd",
"Msal"
"onigasm-umd"
]
},
{

View file

@ -5649,13 +5649,6 @@ ms@^2.1.1:
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
msal@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/msal/-/msal-1.1.3.tgz#d8c501d513f5e52eaf000f20a245526fc1ecaa2a"
integrity sha512-cdShb+N1H3OyR1y46ij6OO7QzeqC6BxrbrNcouS4JBrr1+DnZ55TumxQKEzWmTXHvsbsuz5PCyXZl812Un8L9g==
dependencies:
tslib "^1.9.3"
multimatch@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-2.1.0.tgz#9c7906a22fb4c02919e2f5f75161b4cdbd4b2a2b"
@ -8511,11 +8504,6 @@ tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
tslint@^5.16.0:
version "5.16.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.16.0.tgz#ae61f9c5a98d295b9a4f4553b1b1e831c1984d67"