Fix relative_url_root Web IDE OAuth issues
Issue: Web IDE OAuth: Handle relative url root case (#475276 - closed)
What does this MR do and why?
- Brings back changes from the original MR: Fix relative_url_root Web IDE OAuth issues (!161328 - merged).
- Remove the addition of a trailing slash in the config GitLab URL that was introduced in the original MR. For context, the GitLab Workflow extension relies on this URL not having a trailing slash. Instead, we made a fix to Web IDE: fix: handle relative url case for OAuth (gitlab-web-ide!357 - merged) to gracefully handle presence/no presence of trailing slashes when constructing OAuth URL.
- Upgrades the
@gitlab/web-ide
package. Updates patch name to match the new tag.
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
No relative URL | With relative URL | |
---|---|---|
Correct OAuth redirect URL | ||
Incorrect OAuth redirect URL |
How to set up and validate locally
Setup
- Pull this branch and run
yarn install
To test relative URL
-
Stop GDK with
gdk stop
-
Add
relative_url_root
by runninggdk config set relative_url_root /gitlab
-
Disable vite by running:
gdk config set webpack.enabled true gdk config set vite.enabled false
-
Run
gdk reconfigure
-
In resulting
Procfile
, add-authBackend http://localhost:8080/gitlab
to the end of the line that starts withgitlab-workhorse:
-
Start GDK with
gdk start
-
Visit the GDK at
/gitlab
To test Web IDE OAuth redirect URL mismatch
- Go to
Admin Area
- Select `Applications` and select
GitLab Web IDE
. Edit the application settings' redirect URL and the one with origin matching your window origin. - If you've recently accessed the Web IDE, be sure to remove the
gitlab/web-ide/oauth/<application_id>/token
entry from local storage. - Open Web IDE, should see the error page.
To test fresh Web IDE setup
- Remove the
GitLab Web IDE
application inAdmin Area
. - If you've recently accessed the Web IDE, be sure to remove the
gitlab/web-ide/oauth/<application_id>/token
entry from local storage. - Open Web IDE
Cases I've tested (with relative URL and no relative URL):
- Fresh Web IDE setup: correctly creates OAuth application with correct redirect URL matching the configs
- Open Web IDE with matching redirect URLs: Web IDE works as expected
- Can checkout branches
- Can commit and create MR
- Go to MR and go to project links work
- We see the duo icon
- No unexpected errors in dev console
- Open Web IDE with mismatching redirect URLs:
- See error page
- If multiple domain listed, drop down is rendered
- Suggested domains don't include one matching the current window origin
Edited by Cindy Halim