Package com.axelor.auth
Class MFAService
java.lang.Object
com.axelor.auth.MFAService
Service responsible for managing Multi-Factor Authentication (MFA) for users.
This service handles the configuration, verification, and lifecycle of MFA methods, including TOTP-based apps and email-based verification codes as well as providing recovery methods.
Core functionalities include:
- Generating TOTP secrets and QR codes
- Verifying TOTP tokens and email codes
- Sending email codes via the configured mail service
- Generating and managing sets of recovery codes
- Managing default and valid MFA configurations per user
- Testing MFA setups before activation
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
configureTOTP
(MFA mfa) void
disableMFA
(MFA mfa) void
protected byte[]
generateQRCode
(String secret, String username) generateRecoveryCodes
(MFA mfa) protected String
getEmailRetryAfter
(User user) protected String
getMessage
(String key, Object... arguments) getMethods
(MFA mfa) getMethods
(User user) protected String
getMFAEmailBody
(User user, boolean isConfirmation, String code) protected String
getMFAEmailSubject
(User user, boolean isConfirmation, String code) getRelatedMfa
(User user) getRelatedMfa
(User user, boolean create) protected String
listToString
(List<String> codes) void
removeEmail
(MFA mfa) protected void
removeEmail
(MFA mfa, boolean updateDefault) protected void
removeRecoveryCodes
(MFA mfa) void
removeTOTP
(MFA mfa) protected void
removeTOTP
(MFA mfa, boolean updateDefault) sendEmailCode
(User user) sendEmailConfirmation
(MFA mfa) void
setDefaultMethod
(MFA mfa, MFAMethod method) stringToList
(String codes) void
validateMethod
(MFA mfa, String code, MFAMethod method) boolean
verifyCode
(User user, String mfaCode, String mfaMethod) protected boolean
verifyEmailCode
(MFA mfa, String code) protected boolean
verifyRecoveryCode
(String code, User user)
-
Field Details
-
TOTP_ALGORITHM
public static final dev.samstevens.totp.code.HashingAlgorithm TOTP_ALGORITHM -
TOTP_DIGITS
public static final int TOTP_DIGITS- See Also:
-
TOTP_PERIOD
public static final int TOTP_PERIOD- See Also:
-
EMAIL_CODE_VALIDITY
public static final int EMAIL_CODE_VALIDITY- See Also:
-
EMAIL_SEND_COOL_DOWN
-
CHARACTERS
- See Also:
-
RECOVERY_CODE_PART_LENGTH
public static final int RECOVERY_CODE_PART_LENGTH- See Also:
-
-
Constructor Details
-
MFAService
-
-
Method Details
-
enableMFA
-
disableMFA
-
getMethods
-
getMethods
-
configureTOTP
-
removeTOTP
-
removeTOTP
-
removeEmail
-
removeEmail
-
generateQRCode
-
verifyCode
-
getEmailRetryAfter
-
verifyEmailCode
-
sendEmailCode
-
sendEmailConfirmation
-
getMFAEmailSubject
-
getMFAEmailBody
-
getAppName
-
getMessage
-
validateMethod
-
setDefaultMethod
-
generateRecoveryCodes
-
removeRecoveryCodes
-
verifyRecoveryCode
-
getRelatedMfa
-
getRelatedMfa
-
stringToList
-
listToString
-