diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index d04306f7a6..e4816ad88a 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -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. diff --git a/zerver/tests/test_auth_backends.py b/zerver/tests/test_auth_backends.py index 6fc6f5b2a4..9d43dc777a 100644 --- a/zerver/tests/test_auth_backends.py +++ b/zerver/tests/test_auth_backends.py @@ -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), diff --git a/zerver/views/auth.py b/zerver/views/auth.py index b44d1c51c9..b771da8363 100644 --- a/zerver/views/auth.py +++ b/zerver/views/auth.py @@ -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)