Skip to content

Commit bc943bc

Browse files
committed
Pass in connectionToken
1 parent 3889970 commit bc943bc

5 files changed

Lines changed: 33 additions & 10 deletions

File tree

src/vs/code/browser/workbench/workbench.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
<!-- Workaround to pass product configuration-->
2121
<meta id="vscode-remote-product-configuration" data-settings="{{PRODUCT_CONFIGURATION}}">
22-
23-
<!-- Workaround to pass remote connection token-->
24-
<meta id="vscode-remote-connection-token" data-settings="{{CONNECTION_AUTH_TOKEN}}">
2522
</head>
2623

2724
<body aria-label="">
@@ -35,4 +32,4 @@
3532

3633
<!-- Startup via workbench.js -->
3734
<script src="./out/vs/code/browser/workbench/workbench.js"></script>
38-
</html>
35+
</html>

src/vs/platform/sign/browser/signService.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,28 @@ export class SignService implements ISignService {
1010

1111
_serviceBrand: ServiceIdentifier<ISignService>;
1212

13+
private readonly _tkn: string | null;
14+
15+
constructor(token: string | undefined) {
16+
if (typeof token !== 'undefined') {
17+
this._tkn = token;
18+
} else {
19+
this._tkn = SignService._readTokenFromURL();
20+
}
21+
}
22+
23+
private static _readTokenFromURL(): string | null {
24+
if (!document.location.hash) {
25+
return null;
26+
}
27+
const m = document.location.hash.match(/[#&]tkn=([^&]+)/);
28+
if (!m) {
29+
return null;
30+
}
31+
return m[1];
32+
}
33+
1334
async sign(value: string): Promise<string> {
14-
return Promise.resolve(document.getElementById('vscode-remote-connection-token')!.getAttribute('data-settings')!);
35+
return Promise.resolve(this._tkn || '');
1536
}
16-
}
37+
}

src/vs/workbench/browser/web.main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class CodeRendererMain extends Disposable {
131131
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
132132

133133
// Signing
134-
const signService = new SignService();
134+
const signService = new SignService(this.configuration.connectionToken);
135135
serviceCollection.set(ISignService, signService);
136136

137137
// Remote Agent

src/vs/workbench/services/configuration/test/electron-browser/configurationService.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ suite('WorkspaceContextService - Folder', () => {
107107
const environmentService = new TestEnvironmentService(URI.file(parentDir));
108108
const fileService = new FileService(new NullLogService());
109109
fileService.registerProvider(Schemas.userData, new FileUserDataProvider(environmentService.appSettingsHome, environmentService.backupHome, new DiskFileSystemProvider(new NullLogService()), environmentService));
110-
workspaceContextService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, new RemoteAgentService(<IWindowConfiguration>{}, environmentService, new RemoteAuthorityResolverService(), new SignService()));
110+
workspaceContextService = new WorkspaceService({ configurationCache: new ConfigurationCache(environmentService) }, environmentService, fileService, new RemoteAgentService(<IWindowConfiguration>{}, environmentService, new RemoteAuthorityResolverService(), new SignService(undefined)));
111111
return (<WorkspaceService>workspaceContextService).initialize(convertToWorkspacePayload(URI.file(folderDir)));
112112
});
113113
});
@@ -1630,4 +1630,4 @@ export function getWorkspaceIdentifier(configPath: URI): IWorkspaceIdentifier {
16301630
configPath,
16311631
id: getWorkspaceId(configPath)
16321632
};
1633-
}
1633+
}

src/vs/workbench/workbench.web.api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export interface IWorkbenchConstructionOptions {
1818
*/
1919
remoteAuthority: string;
2020

21+
/**
22+
* The connection token to send to the server.
23+
*/
24+
connectionToken?: string;
25+
2126
/**
2227
* Experimental: An endpoint to serve iframe content ("webview") from. This is required
2328
* to provide full security isolation from the workbench host.
@@ -64,4 +69,4 @@ function create(domElement: HTMLElement, options: IWorkbenchConstructionOptions)
6469

6570
export {
6671
create
67-
};
72+
};

0 commit comments

Comments
 (0)