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) voiddisableMFA(MFA mfa) voidprotected byte[]generateQRCode(String secret, String username) generateRecoveryCodes(MFA mfa) protected StringgetEmailRetryAfter(User user) protected StringgetMessage(String key, Object... arguments) getMethods(MFA mfa) getMethods(User user) protected StringgetMFAEmailBody(User user, boolean isConfirmation, String code) protected StringgetMFAEmailSubject(User user, boolean isConfirmation, String code) getRelatedMfa(User user) getRelatedMfa(User user, boolean create) protected StringlistToString(List<String> codes) voidremoveEmail(MFA mfa) protected voidremoveEmail(MFA mfa, boolean updateDefault) protected voidremoveRecoveryCodes(MFA mfa) voidremoveTOTP(MFA mfa) protected voidremoveTOTP(MFA mfa, boolean updateDefault) sendEmailCode(User user) sendEmailConfirmation(MFA mfa) voidsetDefaultMethod(MFA mfa, MFAMethod method) stringToList(String codes) voidvalidateMethod(MFA mfa, String code, MFAMethod method) booleanverifyCode(User user, String mfaCode, String mfaMethod) protected booleanverifyEmailCode(MFA mfa, String code) protected booleanverifyRecoveryCode(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
-