mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 03:23:50 +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:
@@ -4,8 +4,10 @@ from typing import Dict, Any
|
||||
from django.http import HttpRequest
|
||||
from django.conf import settings
|
||||
import ujson
|
||||
from zerver.models import get_realm_by_string_id
|
||||
from zproject.backends import (password_auth_enabled, dev_auth_enabled,
|
||||
google_auth_enabled, github_auth_enabled)
|
||||
from zerver.lib.utils import get_subdomain
|
||||
|
||||
def add_settings(request):
|
||||
# type: (HttpRequest) -> Dict[str, Any]
|
||||
@@ -13,7 +15,11 @@ def add_settings(request):
|
||||
realm = request.user.realm
|
||||
realm_uri = realm.uri
|
||||
else:
|
||||
realm = None
|
||||
if settings.REALMS_HAVE_SUBDOMAINS:
|
||||
subdomain = get_subdomain(request)
|
||||
realm = get_realm_by_string_id(subdomain)
|
||||
else:
|
||||
realm = None
|
||||
# TODO: Figure out how to add an assertion that this is not used
|
||||
realm_uri = settings.SERVER_URI
|
||||
|
||||
@@ -38,9 +44,9 @@ def add_settings(request):
|
||||
'email_gateway_example': settings.EMAIL_GATEWAY_EXAMPLE,
|
||||
'open_realm_creation': settings.OPEN_REALM_CREATION,
|
||||
'password_auth_enabled': password_auth_enabled(realm),
|
||||
'dev_auth_enabled': dev_auth_enabled(),
|
||||
'google_auth_enabled': google_auth_enabled(),
|
||||
'github_auth_enabled': github_auth_enabled(),
|
||||
'dev_auth_enabled': dev_auth_enabled(realm),
|
||||
'google_auth_enabled': google_auth_enabled(realm),
|
||||
'github_auth_enabled': github_auth_enabled(realm),
|
||||
'development_environment': settings.DEVELOPMENT,
|
||||
'support_email': settings.ZULIP_ADMINISTRATOR,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user