CB-5946 force lowercase userid (#3074)

Co-authored-by: Evgenia <139753579+EvgeniaBzzz@users.noreply.github.com>
This commit is contained in:
Alexander Skoblikov
2024-11-18 09:47:18 +01:00
committed by GitHub
co-authored by Evgenia
parent 5293be4d4a
commit 0943b80942
3 changed files with 9 additions and 3 deletions
@@ -529,7 +529,7 @@ public abstract class CBApplication<T extends CBServerConfig> extends
}
if (isConfigurationMode()) {
finishSecurityServiceConfiguration(adminName, adminPassword, authInfoList);
finishSecurityServiceConfiguration(adminName.toLowerCase(), adminPassword, authInfoList);
}
// Save runtime configuration
@@ -851,8 +851,13 @@ public class CBEmbeddedSecurityController<T extends WebAuthApplication>
}
List<String[]> transformedCredentials;
WebAuthProviderDescriptor authProvider = getAuthProvider(authProviderId);
if (authProvider.isCaseInsensitive() && !isSubjectExists(userId) && isSubjectExists(userId.toLowerCase())) {
log.warn("User with id '" + userId + "' not found, credentials will be set for the user: " + userId.toLowerCase());
userId = userId.toLowerCase();
}
try {
SMAuthCredentialsProfile credProfile = getCredentialProfileByParameters(authProvider, credentials.keySet());
String finalUserId = userId;
transformedCredentials = credentials.entrySet().stream().map(cred -> {
String propertyName = cred.getKey();
AuthPropertyDescriptor property = credProfile.getCredentialParameter(propertyName);
@@ -860,7 +865,7 @@ public class CBEmbeddedSecurityController<T extends WebAuthApplication>
return null;
}
String encodedValue = CommonUtils.toString(cred.getValue());
encodedValue = property.getEncryption().encrypt(userId, encodedValue);
encodedValue = property.getEncryption().encrypt(finalUserId, encodedValue);
return new String[]{propertyName, encodedValue};
}).toList();
} catch (Exception e) {
@@ -17,6 +17,7 @@
package io.cloudbeaver.service.security.db;
import org.jkiss.dbeaver.model.security.user.SMTeam;
import org.jkiss.utils.CommonUtils;
import java.util.List;
@@ -26,7 +27,7 @@ class CBDatabaseInitialData {
private List<SMTeam> teams;
public String getAdminName() {
return adminName;
return CommonUtils.isEmpty(adminName) ? null : adminName.toLowerCase();
}
public String getAdminPassword() {