Resolve "Improve Group SAML authentication failed messages"
Related to #33713 (closed)
What?
This merge request creates clearer error messages and validation conditions for authentication errors related to the SAML NameID/extern_uid.
Why?
Before this improvement, users encountered vague error messages which impacted their ability to debug SAML related errors.
Proposed Solution
Kept here as a reference to the discussion below
Solution
This happens when your current IDP NameID (extern_uid/username) is already in use by another user & associated with a Gitlab account.
-
Message: “SAML authentication failed: Your NameID has already been taken. Please contact your administrator to generate a unique NameID.”
-
Cause & Solution:
Cause Solution Trying to link your existing GitLab.com account (has no SAML identity) with an active session (logged-in) to a Gitlab group via Group SSO Tell your administrator to re-generate a non-duplicate NameID (external_uid) for your IDP account while following GitLab’s NameID constraints. I could not reproduce this & its description is quite confusing. I believe it should be removed especially due to this error message being more relevant: SAML Name ID and email address do not match your user account
Based on my UI tests & the Rails validation, Gitlab does not seem to enforce/check for case-sensitivity, contrary to what is mentioned in the docs. So, NameID values like
abc123andABC123would be treated as the same value.Is this a typo in the documentation that needs to be removed?
4. Ensure there is a sensible error message when NameID is missing:
-
UI Error Change:
- Current Flash Error:
SAML authentication failed: SAML NameID can’t be blank - Proposed:
SAML authentication failed: SAML NameID is not in your response. Please contact your administrator
- Current Flash Error:
-
Docs Change:
- Message: “SAML authentication failed: SAML NameID is not in your response. Please contact your administrator”
- Cause & Solution:
Cause Solution Signed into your Gitlab account via Group SSO but, your SAML response does not have a NameID. Contact your administrator to ensure your IDP has assigned a valid NameID. Verify that your SAML response has a valid NameID. -
UI Error Change:
Steps To Reproduce
-
Extern UID has already been taken
- Create a Gitlab Group
- Create 2 new Gitlab user accounts (user1 & user2) via the
self-registerpage oradmin/userspage - Create an Okta Developer (any IDP works) account & configure Group SOO to the created Gitlab Group
- Create
okta_user1withNameID = 25and link it to your Gitlabuser1 - Sign in your
user2Gitlab account and maintain an active session. - Create
okta_user2withNameID = 25and try to link it to your Gitlabuser2 - The error should pop up here
-
Missing NameID
-
Navigate to
lib/gitlab/auth/omniauth_identity_linker_base.rb& set the returnnilfor theuiddef uid # oauth['uid'] This is the NameID that Gitlab receives from omniauth nil end -
Try to relink a SAML identity from Okta to your Gitlab Group
-
The error should pop up here
-
Documentation MR
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.