auth: Add social_backends to /server_settings.

This commit is contained in:
Mateusz Mandera 2019-10-22 01:33:44 +02:00 committed by Tim Abbott
parent 892d25faa1
commit db29fcbbc4
3 changed files with 12 additions and 3 deletions

View File

@ -2099,6 +2099,11 @@ paths:
description: Each key-value pair in the object indicates
whether the authentication method is enabled on this
server.
social_backends:
type: array
description: List of "social backend" objects, describing which
social backends are enabled and their parameters - most importantly
the login url, display_name and display_logo.
zulip_version:
type: string
description: The version of Zulip running in the server.

View File

@ -33,7 +33,7 @@ from zerver.lib.avatar_hash import user_avatar_path
from zerver.lib.dev_ldap_directory import generate_dev_ldap_dir
from zerver.lib.mobile_auth_otp import otp_decrypt_api_key
from zerver.lib.validator import validate_login_email, \
check_bool, check_dict_only, check_string, Validator
check_bool, check_dict_only, check_list, check_string, Validator
from zerver.lib.request import JsonableError
from zerver.lib.storage import static_path
from zerver.lib.users import get_all_api_keys
@ -57,7 +57,8 @@ from zproject.backends import ZulipDummyBackend, EmailAuthBackend, \
require_email_format_usernames, AUTH_BACKEND_NAME_MAP, \
ZulipLDAPConfigurationError, ZulipLDAPExceptionOutsideDomain, \
ZulipLDAPException, query_ldap, sync_user_from_ldap, SocialAuthMixin, \
PopulateUserLDAPError, SAMLAuthBackend, saml_auth_enabled, email_belongs_to_ldap
PopulateUserLDAPError, SAMLAuthBackend, saml_auth_enabled, email_belongs_to_ldap, \
get_social_backend_dicts
from zerver.views.auth import (maybe_send_to_registration,
_subdomain_token_salt)
@ -1836,10 +1837,12 @@ class FetchAuthBackends(ZulipTestCase):
]
for backend_name_with_case in AUTH_BACKEND_NAME_MAP:
authentication_methods_list.append((backend_name_with_case.lower(), check_bool))
social_backends = get_social_backend_dicts()
self.assert_json_success(result)
checker = check_dict_only([
('authentication_methods', check_dict_only(authentication_methods_list)),
('social_backends', check_list(None, length=len(social_backends))),
('email_auth_enabled', check_bool),
('is_incompatible', check_bool),
('require_email_format_usernames', check_bool),

View File

@ -847,7 +847,8 @@ def api_get_server_settings(request: HttpRequest) -> HttpResponse:
"realm_uri",
"realm_name",
"realm_icon",
"realm_description"]:
"realm_description",
"social_backends"]:
if context[settings_item] is not None:
result[settings_item] = context[settings_item]
return json_success(result)