Skip to content

Commit

Permalink
CB-5946 force lowercase userid
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Nov 15, 2024
1 parent 5bcef92 commit 42a9829
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public synchronized void finishConfiguration(
}

if (isConfigurationMode()) {
finishSecurityServiceConfiguration(adminName, adminPassword, authInfoList);
finishSecurityServiceConfiguration(adminName.toLowerCase(), adminPassword, authInfoList);
}

// Save runtime configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,16 +851,21 @@ public void setUserCredentials(
}
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);
if (property == null) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand Down

0 comments on commit 42a9829

Please sign in to comment.