diff --git a/src/vs/code/browser/workbench/workbench.html b/src/vs/code/browser/workbench/workbench.html index 097dd15b3c5..5b06636edbb 100644 --- a/src/vs/code/browser/workbench/workbench.html +++ b/src/vs/code/browser/workbench/workbench.html @@ -19,9 +19,6 @@ - - - @@ -35,4 +32,4 @@ - \ No newline at end of file + diff --git a/src/vs/platform/sign/browser/signService.ts b/src/vs/platform/sign/browser/signService.ts index 501ab8939d4..164dfaef813 100644 --- a/src/vs/platform/sign/browser/signService.ts +++ b/src/vs/platform/sign/browser/signService.ts @@ -10,7 +10,28 @@ export class SignService implements ISignService { _serviceBrand: ServiceIdentifier; - async sign(value: string): Promise { - return Promise.resolve(document.getElementById('vscode-remote-connection-token')!.getAttribute('data-settings')!); + private readonly _tkn: string | null; + + constructor(token: string | undefined) { + if (typeof token !== 'undefined') { + this._tkn = token; + } else { + this._tkn = SignService._readTokenFromURL(); + } } -} \ No newline at end of file + + private static _readTokenFromURL(): string | null { + if (!document.location.hash) { + return null; + } + const m = document.location.hash.match(/[#&]tkn=([^&]+)/); + if (!m) { + return null; + } + return m[1]; + } + + async sign(value: string): Promise { + return Promise.resolve(this._tkn || ''); + } +} diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts index fadc5132cd2..f37f298931d 100644 --- a/src/vs/workbench/browser/web.main.ts +++ b/src/vs/workbench/browser/web.main.ts @@ -131,7 +131,7 @@ class CodeRendererMain extends Disposable { serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService); // Signing - const signService = new SignService(); + const signService = new SignService(this.configuration.connectionToken); serviceCollection.set(ISignService, signService); // Remote Agent diff --git a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts index 5f4a9ced4a2..e59d6ad40d8 100644 --- a/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts +++ b/src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts @@ -107,7 +107,7 @@ suite('WorkspaceContextService - Folder', () => { const environmentService = new TestEnvironmentService(URI.file(parentDir)); const fileService = new FileService(new NullLogService()); fileService.registerProvider(Schemas.userData, new FileUserDataProvider(environmentService.appSettingsHome, environmentService.backupHome, new DiskFileSystemProvider(new NullLogService()), environmentService)); - workspaceContextService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, new RemoteAgentService({}, environmentService, new RemoteAuthorityResolverService(), new SignService())); + workspaceContextService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, new RemoteAgentService({}, environmentService, new RemoteAuthorityResolverService(), new SignService(undefined))); return (workspaceContextService).initialize(convertToWorkspacePayload(URI.file(folderDir))); }); }); @@ -1630,4 +1630,4 @@ export function getWorkspaceIdentifier(configPath: URI): IWorkspaceIdentifier { configPath, id: getWorkspaceId(configPath) }; -} \ No newline at end of file +} diff --git a/src/vs/workbench/workbench.web.api.ts b/src/vs/workbench/workbench.web.api.ts index d411ccd3280..b1be3bab964 100644 --- a/src/vs/workbench/workbench.web.api.ts +++ b/src/vs/workbench/workbench.web.api.ts @@ -18,6 +18,11 @@ export interface IWorkbenchConstructionOptions { */ remoteAuthority: string; + /** + * The connection token to send to the server. + */ + connectionToken?: string; + /** * Experimental: An endpoint to serve iframe content ("webview") from. This is required * to provide full security isolation from the workbench host. @@ -64,4 +69,4 @@ function create(domElement: HTMLElement, options: IWorkbenchConstructionOptions) export { create -}; \ No newline at end of file +};