mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
auth: Rewrite data model for tracking enabled auth backends.
So far, we've used the BitField .authentication_methods on Realm for tracking which backends are enabled for an organization. This however made it a pain to add new backends (requiring altering the column and a migration - particularly troublesome if someone wanted to create their own custom auth backend for their server). Instead this will be tracked through the existence of the appropriate rows in the RealmAuthenticationMethods table.
This commit is contained in:
committed by
Tim Abbott
parent
41f17bf392
commit
ffa3aa8487
@@ -7,11 +7,13 @@ from zerver.lib.user_groups import create_system_user_groups_for_realm
|
||||
from zerver.models import (
|
||||
Realm,
|
||||
RealmAuditLog,
|
||||
RealmAuthenticationMethod,
|
||||
RealmUserDefault,
|
||||
UserProfile,
|
||||
get_client,
|
||||
get_system_bot,
|
||||
)
|
||||
from zproject.backends import all_implemented_backend_names
|
||||
|
||||
|
||||
def server_initialized() -> bool:
|
||||
@@ -28,6 +30,14 @@ def create_internal_realm() -> None:
|
||||
RealmUserDefault.objects.create(realm=realm)
|
||||
create_system_user_groups_for_realm(realm)
|
||||
|
||||
# We create realms with all authentications methods enabled by default.
|
||||
RealmAuthenticationMethod.objects.bulk_create(
|
||||
[
|
||||
RealmAuthenticationMethod(name=backend_name, realm=realm)
|
||||
for backend_name in all_implemented_backend_names()
|
||||
]
|
||||
)
|
||||
|
||||
# Create some client objects for common requests. Not required;
|
||||
# just ensures these get low IDs in production, and in development
|
||||
# avoids an extra database write for the first HTTP request in
|
||||
|
||||
Reference in New Issue
Block a user