Skip to content

feat(security): add pwned password validation#2959

Open
AlexProgrammerDE wants to merge 2 commits into
AuthMe:masterfrom
AlexProgrammerDE:master
Open

feat(security): add pwned password validation#2959
AlexProgrammerDE wants to merge 2 commits into
AuthMe:masterfrom
AlexProgrammerDE:master

Conversation

@AlexProgrammerDE
Copy link
Copy Markdown

@AlexProgrammerDE AlexProgrammerDE commented Apr 20, 2026

Successor of #2642 because for some reason it was closed unmerged and I didn't get a reply from the maintainers so far. Will update the code to be mergable this evening.

@Xephi
Copy link
Copy Markdown
Contributor

Xephi commented Apr 20, 2026

Successor of #2642 because for some reason it was closed unmerged and I didn't get a reply from the maintainers so far. Will update the code to be mergable this evening.

#2960

Thanks for your contribution, actually it needs some changes to be mergeable yes :)

@Xephi
Copy link
Copy Markdown
Contributor

Xephi commented Apr 22, 2026

Sorry @AlexProgrammerDE , completely reworked the plugin :D

@AlexProgrammerDE AlexProgrammerDE marked this pull request as ready for review April 23, 2026 09:52
Copilot AI review requested due to automatic review settings April 23, 2026 09:53
@AlexProgrammerDE AlexProgrammerDE changed the title Add haveibeenpwned password check feat(security): add pwned password validation Apr 23, 2026
@AlexProgrammerDE
Copy link
Copy Markdown
Author

@Xephi PR is ready for merge/review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional HaveIBeenPwned “Pwned Passwords” range-API check to AuthMe’s password validation so servers can reject commonly breached passwords during registration / password changes.

Changes:

  • Introduces PwnedPasswordService to query the HIBP range API and parse breach counts.
  • Extends ValidationService.validatePassword to optionally reject passwords above a configurable breach-count threshold.
  • Adds message key + English translation and unit tests covering service + validation behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
authme-core/src/main/java/fr/xephi/authme/service/PwnedPasswordService.java New service performing HIBP range API request and parsing response into a pwned-count result.
authme-core/src/main/java/fr/xephi/authme/service/ValidationService.java Wires the pwned-password check into password validation behind a settings flag + threshold.
authme-core/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java Adds config toggles for enabling the check and setting the breach-count threshold.
authme-core/src/main/java/fr/xephi/authme/message/MessageKey.java Adds a new message key + placeholder for breach count.
authme-core/src/main/resources/messages/messages_en.yml Adds the English message text for the new validation error.
authme-core/src/test/java/fr/xephi/authme/service/PwnedPasswordServiceTest.java New unit tests for parsing + request prefix behavior + failure behavior.
authme-core/src/test/java/fr/xephi/authme/service/ValidationServiceTest.java Adds tests for threshold behavior and “unavailable API” behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread authme-core/src/main/java/fr/xephi/authme/service/ValidationService.java Outdated
@Xephi Xephi self-requested a review April 23, 2026 18:37
Copy link
Copy Markdown
Contributor

@Xephi Xephi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should make it thread-safe, take a look at Copilot's review :)

@AlexProgrammerDE
Copy link
Copy Markdown
Author

@Xephi sorry for the delay, is it good now?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Comment on lines +111 to +120
future.complete(validatePwnedPassword(password));
} catch (RuntimeException e) {
future.completeExceptionally(e);
} catch (Error e) {
future.completeExceptionally(e);
}
});
return future;
}

Comment on lines +62 to +66
validatePwnedPassword(parameters).thenAccept(passwordValidation -> {
if (passwordValidation.hasError()) {
service.send(parameters.getPlayer(), passwordValidation.getMessageKey(),
passwordValidation.getArgs());
} else {
Comment on lines +51 to 55
validationService.validatePasswordAsync(playerPass, playerName).thenAccept(passwordValidation -> {
if (passwordValidation.hasError()) {
commonService.send(sender, passwordValidation.getMessageKey(), passwordValidation.getArgs());
return;
}
Comment on lines +56 to +60
validationService.validatePasswordAsync(newPassword, name).thenAccept(passwordValidation -> {
if (passwordValidation.hasError()) {
commonService.send(player, passwordValidation.getMessageKey(), passwordValidation.getArgs());
} else {
management.performPasswordChange(player, oldPassword, newPassword);
Comment on lines +33 to +38
validationService.validatePasswordAsync(playerPass, playerName).thenAccept(validationResult -> {
if (validationResult.hasError()) {
commonService.send(sender, validationResult.getMessageKey(), validationResult.getArgs());
} else {
management.performPasswordChangeAsAdmin(sender, playerName, playerPass);
}
Comment on lines 19 to 22
name_in_password: '&cYou can''t use your name as password, please choose another one...'
unsafe_password: '&cThe chosen password isn''t safe, please choose another one...'
pwned_password: '&cYour chosen password is not secure. It has been seen %pwned_count times before! Please use a stronger password...'
forbidden_characters: '&4Your password contains illegal characters. Allowed chars: %valid_chars'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants