We do not have LDAP group membership configured for SonarQube however.
What are we missing in terms of configuration or could this possibly be a genuine bug?
Also, when sonar.authenticator.downcase is set to true, does SonarQube automatically lowercase other LDAP-related values, such as group names or search attributes?
When you say “breaks LDAP login” – what do you mean? More specifically – can new users login, but existing users with non-lowercase user IDs (on SonarQube) can’t?
What I’m trying to get at is – if all your users should now have a lowercase username, you are going to update the existing users to also have a lowercase uesrname, either using PATCH /api/v2/users-management/users/{id} or (more simply, but deprecated) POST api/projects/update_login.
To clarify, I’m confirming whether a new user logging into SonarQube for the first time is successful. If the login works, then your login system is functioning correctly, and you just need to update the existing logins as I previously mentioned. This is just to ensure we’re addressing the real problem.
Hey Colin, thanks for the info/clarification! This work has just resurfaced for us. I haven’t been able to confirm a successful login for a new LDAP-synced user, but I have confirmed that new local (non-LDAP) user logins work correctly when sonar.authenticator.downcase=true is enabled.
I also ran some local tests to try setting usernames to lowercase as you suggested, but I’m running into what seem to be syntax errors
Does this syntax look correct for updating the user’s login? curl -v -X PATCH "https://<domain>/api/v2/users-management/users/<user-id>" \ -H "Accept: application/json, text/plain, */*" \ -H "Content-Type: application/merge-patch+json" \ -u <token>: \ --data '{"login":{"value":"updated-name","defined":true}}'
The request works for updating other user fields (like name), but fails when I try to update the login.
Just tried it out myself. I think we have a docs issue. This curl command, where just a string is defined as login (no value or defined attributes) worked perfectly.
@Colin Thanks that worked! Though it seems updating the login to all lowercase does not prevent the failed login for an LDAP-synced account when the username is set to all lowercase and sonar.authenticator.downcase=True.
I noticed there’s an externalLogin field that I could try updating, but would modifying it break the synchronization between SonarQube and the LDAP service?
Looking at the options available to you in the Web API Docs:
login is SonarQube’s internal user value; it doesn’t necessarily sync with LDAP and is only used within SonarQube.
externalId is typically unique to integrations with DevOps platforms (like Azure DevOps or GitHub).
externalLogin should align with the identifier used in LDAP. If your LDAP server is case-insensitive, changing the case won’t cause problems.
So I think updating externalLogin is the way to go.
Before making any changes in production, I suggest test these adjustments with a single user or on a non-production environment to ensure everything works as expected.