Returns the dictionary containing information on all supported methods with information about whether they're registered for the current user, or not. It returns information in this format: { : { "mfa": , "registere
()
| 65 | |
| 66 | |
| 67 | def mfa_suppored_methods() -> dict: |
| 68 | """ |
| 69 | Returns the dictionary containing information on all supported methods with |
| 70 | information about whether they're registered for the current user, or not. |
| 71 | |
| 72 | It returns information in this format: |
| 73 | { |
| 74 | <auth_method_name>: { |
| 75 | "mfa": <MFA Auth Object>, |
| 76 | "registered": True|False |
| 77 | }, |
| 78 | ... |
| 79 | } |
| 80 | |
| 81 | Returns: |
| 82 | dict: List of all supported MFA methods with the flag for the |
| 83 | registered with the current user or not. |
| 84 | """ |
| 85 | supported_mfa_auth_methods = dict() |
| 86 | |
| 87 | for auth_method in config.MFA_SUPPORTED_METHODS: |
| 88 | registry = MultiFactorAuthRegistry.get(auth_method) |
| 89 | supported_mfa_auth_methods[registry.name] = { |
| 90 | "mfa": registry, "registered": False |
| 91 | } |
| 92 | |
| 93 | auths = UserMFA.query.filter_by(user_id=current_user.id).all() |
| 94 | |
| 95 | for auth in auths: |
| 96 | if auth.mfa_auth in supported_mfa_auth_methods: |
| 97 | supported_mfa_auth_methods[auth.mfa_auth]['registered'] = True |
| 98 | |
| 99 | return supported_mfa_auth_methods |
| 100 | |
| 101 | |
| 102 | def user_supported_mfa_methods(): |
no test coverage detected