feat: Proxy extHost load module through messagePort
- VSCode Fork: feat: Proxy extHost load module through message... (!76 - merged)
- Web IDE: feat: Add cross origin extension host (gitlab-web-ide!293 - merged)
Description
See this thread for more context.
the situation:
- For us to securely enable extension marketplace we need to resolve https://gitlab.com/gitlab-org/gitlab-web-ide/-/issues/150+ by adding
webEndpointUrlTemplate
in workbench configuration. - This creates a separate origin for extensions.
- This creates CORS issue when extension tries to pull assets when starting up.
- VSCode expects the extensions assets to be hosted somewhere that enables CORS. Since the Web IDE is self-hosted we don't really have control of how the Web IDE assets are self hosted. Right now we don't require any CORS headers and this would be a breaking change for many users/customers.
the solution:
Proxy fetch
to the outer context through messagePorts
API since we're already using that. This allows us to work around CORS by proxying the request to the relevant origin.
How to test?
-
In Web IDE, checkout out the branch for this MR feat: Add cross origin extension host (gitlab-web-ide!293 - merged)
-
Apply this patch in Web IDE:
diff --git a/packages/vscode-bootstrap/src/start.ts b/packages/vscode-bootstrap/src/start.ts index 425afff..1fcd1ce 100644 --- a/packages/vscode-bootstrap/src/start.ts +++ b/packages/vscode-bootstrap/src/start.ts @@ -92,12 +92,12 @@ const BASE_OPTIONS: Partial<IWorkbenchConstructionOptions> = { privacyStatementUrl: '', showTelemetryOptOut: false, // 'commit' should be same as vscode_version.json - commit: 'cc647a6c3fe1bc82cbcae763de7ec0939cc092c3', + commit: '70051d40636e6d3e6b5f14ead1c4f12761b98e9e', quality: 'stable', webviewContentExternalBaseUrlTemplate: - 'https://{{uuid}}.cdn.web-ide.gitlab-static.net/web-ide-vscode/{{quality}}/{{commit}}/out/vs/workbench/contrib/webview/browser/pre/', + 'https://{{uuid}}.staging.cdn.web-ide.gitlab-static.net/web-ide-vscode/{{quality}}/{{commit}}/out/vs/workbench/contrib/webview/browser/pre/', webEndpointUrlTemplate: - 'https://{{uuid}}.cdn.web-ide.gitlab-static.net/web-ide-vscode/{{quality}}/{{commit}}', + 'https://{{uuid}}.staging.cdn.web-ide.gitlab-static.net/web-ide-vscode/{{quality}}/{{commit}}', trustedExtensionAuthAccess: ['gitlab.gitlab-workflow', 'gitlab.gitlab-web-ide'], }, };
-
Start Web IDE with
yarn run start:example
and visit with a custom host setup in/etc/host
.
Screenshot
Before | After |
---|---|
Edited by Paul Slaughter