Isolate Web IDE on separate origin
Issue: Use .cdn.web-ide.gitlab-static.net to load Web ... (#520263 - closed)
What does this MR do and why?
Feature flag rollout issue: [Feature flag] Rollout of `web_ide_multi_domain` (#526529 - closed)
This merge request changes the origin used to load the Web IDE's VSCode workbench on gitlab.com. This change is behind a feature flag. After this change, the Web IDE's VSCode workbench will be loaded from the following URL https://workbench-${workbenchDomain}.cdn.web-ide.gitlab-static.net/gitlab-web-ide-vscode-workbench-${workbenchVersion} where:
-
workbenchDomainis a base64-encoded string generated based on the GitLab instance's origin and the current username. -
workbenchVersionis the@gitlab/web-idenpm package's version.
What is the Web IDE's VSCode workbench?
The Web IDE's VSCode workbench is the core VSCode component that provides basic editing capabilities, the editor UI, and orchestrates 3rd-party extensions.
Why
The goal of this change is fully isolating the Web IDE from the GitLab Rails application. The Web IDE's VSCode workbench is embedded in the GitLab Rails application using an iframe. Both the GitLab Rails application and the Web IDE's VSCode workbench are hosted in the same domain therefore they share the same origin. By moving the Web IDE's VSCode workbench to a separate domain, we take advantage of the Web Browser's same-origin policy to ensure that the Web IDE can only communicate with the GitLab Rails application via message channel API.
After this change, the Web IDE's iframe won't have access to the GitLab Rails:
-
windowobject. localStorage-
documentorlocationobjects.
This ensures that the Web IDE and 3rd-party extensions are completely isolated and can't access sensible user data.
References
Screenshots or screen recordings
This merge request doesn't introduce user facing changes. The following video demonstrates how to verify that the Web IDE is, in fact, served from on a separate origin.
How to set up and validate locally
- In
<gdk-dir>/env.runit, add this expression to simulate gitlab.comexport GITLAB_SIMULATE_SAAS=1. - Run
gdk reconfigure && gdk restart. - Enable the
web_ide_multi_domainfeature flag in your local environment. - Open the Web IDE on any project or file.
- The Web IDE should continue working as usual.
- If you inspect the Web IDE's page, the iframe used to embed the Web IDE uses a URL based on
.cdn.web-ide.gitlab-static.net.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
