#1141 Fixes to TOTP implementation

- Revert back to SHA1 as HMAC hash function so that it works with Google authenticator
- Add message to user to tell him to run /2fa confirm to add a TOTP code
This commit is contained in:
ljacqu
2018-04-22 11:13:27 +02:00
parent de0e588cf3
commit 29ac3a7022
39 changed files with 510 additions and 149 deletions
@@ -563,10 +563,11 @@ public class CommandInitializer {
// Register the base totp code
CommandDescription.builder()
.parent(null)
.parent(totpBase)
.labels("code", "c")
.description("Command for logging in")
.detailedDescription("Processes the two-factor authentication code during login.")
.withArgument("code", "The TOTP code to use to log in", MANDATORY)
.executableCommand(TotpCodeCommand.class)
.register();
@@ -35,6 +35,7 @@ public class AddTotpCommand extends PlayerCommand {
TotpGenerationResult createdTotpInfo = generateTotpService.generateTotpKey(player);
messages.send(player, MessageKey.TWO_FACTOR_CREATE,
createdTotpInfo.getTotpKey(), createdTotpInfo.getAuthenticatorQrCodeUrl());
messages.send(player, MessageKey.TWO_FACTOR_CREATE_CONFIRMATION_REQUIRED);
} else {
messages.send(player, MessageKey.TWO_FACTOR_ALREADY_ENABLED);
}