Use only the local-name of an email for the SSH usernames
This way users connect to "you@gerrit.com" rather than the much longer (and uglier) "you@gmail.com@gerrit.com". We still generate the user from the email, preventing end-users from selecting their own SSH name. We could in the future change this if there is sufficient demand. Because we validate both the username and the SSH public key we can only run into name duplication problems if multiple accounts have the same local name in their preferred email address and use the same SSH public key, which should only be possible if they are both using "root@..." as their email and both keys were created on Debian with the infamous broken ssh-keygen implementation. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -146,15 +146,15 @@ public class SshUtil {
|
||||
/** Invalidate all cached keys for the given account. */
|
||||
public static void invalidate(final Account acct) {
|
||||
if (acct != null) {
|
||||
invalidate(acct.getPreferredEmail());
|
||||
invalidate(acct.getSshUserName());
|
||||
}
|
||||
}
|
||||
|
||||
/** Invalidate all cached keys for the given account. */
|
||||
public static void invalidate(final String username){
|
||||
public static void invalidate(final String username) {
|
||||
synchronized (keys) {
|
||||
keys.remove(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Locate keys for the requested account whose email matches the name given. */
|
||||
@@ -172,7 +172,7 @@ public class SshUtil {
|
||||
final ReviewDb db = rdf.open();
|
||||
try {
|
||||
final List<Account> matches =
|
||||
db.accounts().byPreferredEmail(username).toList();
|
||||
db.accounts().bySshUserName(username).toList();
|
||||
if (matches.isEmpty()) {
|
||||
return Collections.<AccountSshKey> emptyList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user