Authentication Provider based on cross-origin-channel
Issue: Adapt OAuth2 client to work when Web IDE is hos... (#420 - closed)
What does this MR do and why?
This merge request introduces changes to support a dedicated Web IDE origin by ensuring that OAuth authentication securely works across origins. It adds a new authentication provider that uses a cross-origin communication channel, allowing the Web IDE to securely communicate with its parent window. The new authentication provider is behind dedicatedWebIDEOrigin feature flag which is enabled by default on the Web IDE's test server. There are two main classes introduced in this MR:
-
PortChannelAuthProviderimplements theAuthenticationProviderinterface that is used by the GitLab's API client to obtain access tokens to authenticate API requests. This class obtains an access token by sending a message via aPortChannelobject to request access tokens to the GitLab instance's origin. It also listens foraccess-token-changedmessages to notify when an OAuth access token expires. -
AuthPortChannelControllerhandles the access token requests sent byPortChannelAuthProvider. It depends on theOAuthClientclass to obtain access tokens and detect when the access token changes.
Other changes
This MR also moves the cleanWebIDEExtensions module to the vscode-bootstrap package in preparation for using multiple origins. Once the Web IDE uses a separate origin for the VSCode's workbench, VSCode's indexedDB database won't be accessible from the GitLab's instance origin.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
This MR doesn't introduce visual changes.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Run the Web IDE test server
yarn start:example. - Make sure all the Web IDE's functionality is working as usual.
- Keep the Web IDE's browser tab open for 1 hour without interacting with it.
- Repeat step 2. This will ensure that the refresh mechanism for OAuth access tokens still works.
