mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
auth: Make supported authentication backends a bitfield on realm.
This makes it possible to configure only certain authentication methods to be enabled on a per-realm basis. Note that the authentication_methods_dict function (which checks what backends are supported on the realm) requires an in function import due to a circular dependency.
This commit is contained in:
@@ -36,8 +36,12 @@ def pad_method_dict(method_dict):
|
||||
|
||||
def auth_enabled_helper(backends_to_check, realm):
|
||||
# type: (List[text_type], Optional[Realm]) -> bool
|
||||
enabled_method_dict = dict((method, True) for method in Realm.AUTHENTICATION_FLAGS)
|
||||
pad_method_dict(enabled_method_dict)
|
||||
if realm is not None:
|
||||
enabled_method_dict = realm.authentication_methods_dict()
|
||||
pad_method_dict(enabled_method_dict)
|
||||
else:
|
||||
enabled_method_dict = dict((method, True) for method in Realm.AUTHENTICATION_FLAGS)
|
||||
pad_method_dict(enabled_method_dict)
|
||||
for supported_backend in django.contrib.auth.get_backends():
|
||||
for backend_name in backends_to_check:
|
||||
backend = AUTH_BACKEND_NAME_MAP[backend_name]
|
||||
|
||||
Reference in New Issue
Block a user