Skip to content

Commit

Permalink
Fix duplicate users due to config keys not supporting upper and lower…
Browse files Browse the repository at this point in the history
… case
  • Loading branch information
TFyre committed Oct 9, 2024
1 parent d5735a2 commit cd00513
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import java.security.Security;
import java.security.spec.InvalidKeySpecException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.wildfly.security.credential.PasswordCredential;
import org.wildfly.security.evidence.PasswordGuessEvidence;
Expand All @@ -44,8 +46,10 @@ public void postConstruct() {
map.put(userPass, new User(BcryptUtil.bcryptHash(userPass), SystemRoles.ROLE_ADMIN));
return;
}
final Set<String> seen = new HashSet<>();
map.putAll(config.users().entrySet()
.stream()
.filter(e -> seen.add(e.getKey().toLowerCase()))
.collect(Collectors.toMap(e -> e.getKey().toLowerCase(), e -> {
String password = e.getValue().password();
if (ModularCrypt.identifyAlgorithm(password.toCharArray()) == null) {
Expand Down

0 comments on commit cd00513

Please sign in to comment.