diff --git a/src/vs/code/electron-main/auth.ts b/src/vs/code/electron-main/auth.ts index 1d2f732c33e..e03d4b8a527 100644 --- a/src/vs/code/electron-main/auth.ts +++ b/src/vs/code/electron-main/auth.ts @@ -6,6 +6,7 @@ import { localize } from 'vs/nls'; import { Disposable } from 'vs/base/common/lifecycle'; import { Event } from 'vs/base/common/event'; +import { URI } from 'vs/base/common/uri'; import { BrowserWindow, BrowserWindowConstructorOptions, app, AuthInfo, WebContents, Event as ElectronEvent } from 'electron'; type LoginEvent = { @@ -58,10 +59,12 @@ export class ProxyAuthHandler extends Disposable { show: true, title: 'VS Code', webPreferences: { - nodeIntegration: true, + preload: URI.parse(require.toUrl('vs/base/parts/sandbox/electron-browser/preload.js')).fsPath, enableWebSQL: false, + sandbox: true, + devTools: false, enableRemoteModule: false, - nativeWindowOpen: true + v8CacheOptions: 'bypassHeatCheck' } }; @@ -72,24 +75,27 @@ export class ProxyAuthHandler extends Disposable { } const win = new BrowserWindow(opts); - const config = {}; - const baseUrl = require.toUrl('vs/code/electron-browser/proxy/auth.html'); - const url = `${baseUrl}?config=${encodeURIComponent(JSON.stringify(config))}`; + const url = require.toUrl('vs/code/electron-sandbox/proxy/auth.html'); const proxyUrl = `${authInfo.host}:${authInfo.port}`; const title = localize('authRequire', "Proxy Authentication Required"); const message = localize('proxyauth', "The proxy {0} requires authentication.", proxyUrl); - const data = { title, message }; - const javascript = 'promptForCredentials(' + JSON.stringify(data) + ')'; const onWindowClose = () => cb('', ''); win.on('close', onWindowClose); win.setMenu(null); - win.loadURL(url); - win.webContents.executeJavaScript(javascript, true).then(({ username, password }: Credentials) => { - cb(username, password); + win.webContents.on('did-finish-load', () => { + const data = { title, message }; + win.webContents.send('vscode:openProxyAuthDialog', data); + }); + win.webContents.on('ipc-message', (event, channel, credentials: Credentials) => { + if (channel === 'vscode:proxyAuthResponse') { + const { username, password } = credentials; + cb(username, password); + } win.removeListener('close', onWindowClose); win.close(); }); + win.loadURL(url); } } diff --git a/src/vs/code/electron-browser/proxy/auth.html b/src/vs/code/electron-sandbox/proxy/auth.html similarity index 58% rename from src/vs/code/electron-browser/proxy/auth.html rename to src/vs/code/electron-sandbox/proxy/auth.html index e5cc351b14a..788b68fce72 100644 --- a/src/vs/code/electron-browser/proxy/auth.html +++ b/src/vs/code/electron-sandbox/proxy/auth.html @@ -5,7 +5,7 @@
+ content="default-src 'none'; img-src 'self' https: data:; media-src 'none'; child-src 'self'; object-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' https:; font-src 'self' https:;">