Page MenuHomePhabricator

Gerrit's ui does not correctly capitalise usernames in the git clone command
Closed, ResolvedPublic

Description

Since we enabled ldap lower case username, gerrit's ui lowercased it in the commands.

But gerrit's doc say you carn't have upper or lowercase, it has to match the username you set.

But in gerrit's ui it is lowercasing it.

Event Timeline

linked upstream ticket was "won't fix"ed back in 2017 with comment "You can use auth.userNameToLowerCase for this." but Paladox replied "i did try that but it broke ssh". status nowadays unclear

hashar claimed this task.
hashar subscribed.

ldap.accountSshUserName default to the field uid.

From mediawiki/extensions/LdapAuthentication:

includes/LdapAuthenticationPlugin.php
        $username = $user->getName();
        if ( $this->getConf( 'LowerCaseUsername' ) ) {
            $username = strtolower( $username );
        }
...
            $values = [ 'uid' => $username ];

The configuration set via:

$wgLDAPLowerCaseUsername = [ 'labs' => false, 'invaliddomain' => false ];

Then looking in LDAP all uid are in lower case so I guess it is normalized to lower case somewhere.

If need be we can set Gerrit auth.userNameToLowerCase=true it says:

If set the username that is received to authenticate a git operation is converted to lower case for looking up the user account in Gerrit.

By setting this parameter a case insensitive authentication for the git operations can be achieved, if it is ensured that the usernames in Gerrit (scheme username) are stored in lower case (e.g. if the parameter ldap.accountSshUserName is set to ${sAMAccountName.toLowerCase}). It is important that for all existing accounts this username is already in lower case. It is not possible to convert the usernames of the existing accounts to lower case because this would break the access to existing per-user branches and Gerrit provides no tool to do such a conversion. Accounts created using the REST API or the create-account SSH command will be created with all lowercase characters, when this option is set.

Setting this parameter to true will prevent all users from login that have a non-lower-case username.

This parameter only affects git over http and git over SSH traffic.

By default this is set to false.

I have checked the Gerrit user database (All-Users.git under refs/meta/external-id) using git grep -P 'username: .*[A-Z].*' and that yields no result. So all accounts are in lower case.

We might had the trouble when we turned on ldap.localUsernameToLowerCase=true (https://gerrit.wikimedia.org/r/c/operations/puppet/+/326150) which caused some havoc here but all those have been fixed afaik (the last task on that front was T323135).