MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / mfa_suppored_methods

Function mfa_suppored_methods

web/pgadmin/authenticate/mfa/utils.py:67–99  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

65
66
67def 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
102def user_supported_mfa_methods():

Callers 2

registration_viewFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected