Skip to content

Commit

Permalink
handle null credentials
Browse files Browse the repository at this point in the history
Signed-off-by: Max Thonagel <[email protected]>
  • Loading branch information
thoniTUB committed Feb 28, 2024
1 parent 5cfc73a commit 7d5d22c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class LocalAuthenticationRealm extends AuthenticatingRealm implements Con

private static final int ENVIRONMNENT_CLOSING_RETRYS = 2;
private static final int ENVIRONMNENT_CLOSING_TIMEOUT = 2; // seconds
// Get the path for the storage here so it is set when as soon the first class is instantiated (in the ManagerNode)
// Get the path for the storage here, so it is set as soon the first class is instantiated (in the ManagerNode)
// In the DistributedStandaloneCommand this directory is overriden multiple times before LocalAuthenticationRealm::onInit for the ShardNodes, so this is a problem.
private final File storageDir;

Expand Down Expand Up @@ -165,7 +165,7 @@ private HashEntry toHashEntry(CredentialType credential) {
if (credential instanceof PasswordCredential passwordCredential) {
return new HashEntry(Password.hash(passwordCredential.password())
.with(defaultHashingFunction)
.getResult()); //.with(defaultHashingFunction).getResult());
.getResult());
}
else if (credential instanceof PasswordHashCredential passwordHashCredential) {
return new HashEntry(passwordHashCredential.hash());
Expand Down Expand Up @@ -212,6 +212,11 @@ public boolean addUser(@NonNull User user, @NonNull CredentialType credential) {
@Override
public boolean updateUser(User user, CredentialType credential) {

if (credential == null) {
log.warn("Skipping user '{}' because no credential was provided", user.getId());
return false;
}

try {
final HashEntry hashEntry = toHashEntry(credential);
passwordStore.update(user.getId(), hashEntry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ConqueryAuthenticationRealm createRealm(ManagerNode manager) {
final BenchmarkResult<BcryptFunction> result = SystemChecker.benchmarkBcrypt(BCRYPT_MAX_MILLISECONDS);

final BcryptFunction prototype = result.getPrototype();
int rounds = prototype.getLogarithmicRounds(); // 12
int rounds = prototype.getLogarithmicRounds();
long realElapsed = result.getElapsed();


Expand Down

0 comments on commit 7d5d22c

Please sign in to comment.