Web IDE: handle SSO redirect during authorization
Issue: Web IDE Endpoints do not Redirect to SSO Provid... (#424770 - closed)
What does this MR do and why?
Users signed in with GitLab but not authenticated via group SSO receive a 404 when attempting to access the Web IDE for projects under that group. To solve this case the Web IDE authorization logic is updated to redirect the user to the SSO provider with the help of an existing helper: find_routable!.
References
Web IDE Endpoints do not Redirect to SSO Provid... (#424770 - closed)
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
| Before | After |
|---|---|
|
before Signed in to GitLab, not signed in via SSO 404 when attempting to access the Web IDE for a project under an SSO enforced group. |
not_logged_in_sso.mov Signed in to GitLab, not signed in via SSO Redirected to identity provider sign in page. After successful authentication, redirected back to Web IDE. |
|
logged_in_sso.mov Signed in to GitLab and SSO Not redirected to identity provider sign in page. Can access the Web IDE. |
|
|
regression No SSO enabled (regression case) Web IDE redirect works as expected. |
How to set up and validate locally
Setup
The steps below assume that:
- SSO is configured for the
GitLab Orggroup - You are running GDK with HTTPS enabled in port 3443:
https://gdk.test:3443/.
Make sure to modify these parameters accordingly in the steps if your local setup is different.
-
Follow steps outlined in this doc to setup SAML in the GDK. Note: to configure the group: sign in as admin root, visit the
Gitlab Orggroup, and selectSettings>SAML SSO -
Don't sign in yet
-
Bypass the verification email via the Rails console:
user = User.find_by_username 'user_1' user.confirmed_at = Time.now user.save -
We want to create a password for the user so we can simulate being signed in to GitLab but not authenticated via SSO. In a separate browser/incognito mode, sign in as the user via SSO by visiting:
https://gdk.test:3443/groups/gitlab-org/-/saml/sso. Username:user1, password:user1pass. -
Once authenticated as
user_1, go toUser Preferences>Passwordand set a password.
Validate locally
- In your default browser, sign in to GitLab as
user_1by visiting/users/sign_inand entering the GitLab password. Do not log in via SSO. Once authenticated, visit the project belonging to the group via URL:https://gdk.test:3443/gitlab-org/gitlab-shell. - Note that you no longer see a
404page and are instead redirected to the identity provider sign in page. - Enter the SSO credentials and sign in.
- Observe that you are redirected to the Web IDE for the project.
- Now that you are authenticated with GitLab and SSO, reload the Web IDE. Observe that you are not redirected to the identity provider's sign in page.