#1141 Fix review remarks by @games647
- Use SHA512 to generate keys instead of default SHA1 - Declare google authenticator dependency as optional and add relocation rule
This commit is contained in:
@@ -197,7 +197,7 @@ public enum MessageKey {
|
||||
/** Your secret code is %code. You can scan it from here %url */
|
||||
TWO_FACTOR_CREATE("two_factor.code_created", "%code", "%url"),
|
||||
|
||||
/** Please submit your two-factor authentication code with /2fa code <code>. */
|
||||
/** Please submit your two-factor authentication code with /2fa code <code>. */
|
||||
TWO_FACTOR_CODE_REQUIRED("two_factor.code_required"),
|
||||
|
||||
/** Two-factor authentication is already enabled for your account! */
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package fr.xephi.authme.security.totp;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.warrenstrange.googleauth.GoogleAuthenticator;
|
||||
import com.warrenstrange.googleauth.GoogleAuthenticatorConfig;
|
||||
import com.warrenstrange.googleauth.GoogleAuthenticatorConfig.GoogleAuthenticatorConfigBuilder;
|
||||
import com.warrenstrange.googleauth.GoogleAuthenticatorKey;
|
||||
import com.warrenstrange.googleauth.GoogleAuthenticatorQRGenerator;
|
||||
import com.warrenstrange.googleauth.HmacHashFunction;
|
||||
import com.warrenstrange.googleauth.IGoogleAuthenticator;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,16 +20,20 @@ public class TotpAuthenticator {
|
||||
private final IGoogleAuthenticator authenticator;
|
||||
private final BukkitService bukkitService;
|
||||
|
||||
|
||||
@Inject
|
||||
TotpAuthenticator(BukkitService bukkitService) {
|
||||
this(new GoogleAuthenticator(), bukkitService);
|
||||
this.authenticator = createGoogleAuthenticator();
|
||||
this.bukkitService = bukkitService;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
TotpAuthenticator(IGoogleAuthenticator authenticator, BukkitService bukkitService) {
|
||||
this.authenticator = authenticator;
|
||||
this.bukkitService = bukkitService;
|
||||
/**
|
||||
* @return new Google Authenticator instance
|
||||
*/
|
||||
protected IGoogleAuthenticator createGoogleAuthenticator() {
|
||||
GoogleAuthenticatorConfig config = new GoogleAuthenticatorConfigBuilder()
|
||||
.setHmacHashFunction(HmacHashFunction.HmacSHA512)
|
||||
.build();
|
||||
return new GoogleAuthenticator(config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user