diff --git a/templates/zerver/apple-error.md b/templates/zerver/apple-error.md deleted file mode 100644 index c5de799fd0..0000000000 --- a/templates/zerver/apple-error.md +++ /dev/null @@ -1,17 +0,0 @@ -You are attempting to use the **Apple auth backend**, but it is not -properly configured. To configure, please check the following: - -* You have registered `{{ root_domain_uri }}/complete/apple/` - as the callback URL for your Services ID in Apple's developer console. You can - enable "Sign in with Apple" for an app at - [Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/). - -* You have set `SOCIAL_AUTH_APPLE_SERVICES_ID`, - `SOCIAL_AUTH_APPLE_APP_ID`, `SOCIAL_AUTH_APPLE_TEAM`, - and `SOCIAL_AUTH_APPLE_KEY` in `{{ - settings_path }}` and stored the private key provided by Apple at - `/etc/zulip/apple-auth-key.p8` on the Zulip server, with - proper permissions set. - -* Navigate back to the login page and attempt the "Sign in with Apple" - flow again. diff --git a/templates/zerver/authentication_backends/apple-error.html b/templates/zerver/authentication_backends/apple-error.html new file mode 100644 index 0000000000..eb8bfd5c34 --- /dev/null +++ b/templates/zerver/authentication_backends/apple-error.html @@ -0,0 +1,28 @@ +

+ You are attempting to use the Apple auth backend, but it is + not properly configured. To configure, please check the following: +

+ diff --git a/templates/zerver/authentication_backends/dev-not-supported-error.html b/templates/zerver/authentication_backends/dev-not-supported-error.html new file mode 100644 index 0000000000..a41487b7e5 --- /dev/null +++ b/templates/zerver/authentication_backends/dev-not-supported-error.html @@ -0,0 +1,19 @@ +

+ You attempted to use the DevAuthBackend authentication method, + which is used for logging in without a password in the Zulip development + environment. +

+

This backend is not available for this realm, either because:

+ diff --git a/templates/zerver/authentication_backends/github-error.html b/templates/zerver/authentication_backends/github-error.html new file mode 100644 index 0000000000..1055a63f0d --- /dev/null +++ b/templates/zerver/authentication_backends/github-error.html @@ -0,0 +1,23 @@ +

+ You are attempting to use the GitHub auth backend, but it + is not properly configured. To configure, please check the following: +

+ diff --git a/templates/zerver/authentication_backends/gitlab-error.html b/templates/zerver/authentication_backends/gitlab-error.html new file mode 100644 index 0000000000..69bd00893c --- /dev/null +++ b/templates/zerver/authentication_backends/gitlab-error.html @@ -0,0 +1,23 @@ +

+ You are attempting to use the GitLab auth backend, but it + is not properly configured. To configure, please check the following: +

+ diff --git a/templates/zerver/authentication_backends/google-error.html b/templates/zerver/authentication_backends/google-error.html new file mode 100644 index 0000000000..2d441a97c0 --- /dev/null +++ b/templates/zerver/authentication_backends/google-error.html @@ -0,0 +1,26 @@ +

+ You are attempting to use the Google auth backend, but it + is not properly configured. To configure, please check the following: +

+ diff --git a/templates/zerver/config_error.html b/templates/zerver/config_error.html index a2cbe824cd..dd3745686f 100644 --- a/templates/zerver/config_error.html +++ b/templates/zerver/config_error.html @@ -48,23 +48,26 @@ {% endif %} {% if error_name == "dev_not_supported_error" %} - {{ render_markdown_path('zerver/dev-not-supported-error.md', {"settings_path": settings_path}) }} + {% include "zerver/authentication_backends/dev-not-supported-error.html" %} {% endif %} - {% if has_markdown_file %} + {% if has_error_template %} {% if development_environment %} - {{ render_markdown_path('zerver/'+social_backend_name+'-error.md', - {"root_domain_uri": root_domain_uri, "settings_path": secrets_path, "secrets_path": secrets_path, - "client_id_key_name": "social_auth_" + social_backend_name + "_key"}) }} + {% with %} + {% set settings_path = secrets_path %} + {% set client_id_key_name = "social_auth_" + social_backend_name + "_key" %} + {% include "zerver/authentication_backends/" + social_backend_name + "-error.html" %} + {% endwith %}

For more information, have a look at the authentication setup guide for the development environment.

{% else %} - {{ render_markdown_path('zerver/'+social_backend_name+'-error.md', - {"root_domain_uri": root_domain_uri, "settings_path": settings_path, "secrets_path": secrets_path, - "client_id_key_name": "SOCIAL_AUTH_" + social_backend_name.upper() + "_KEY"}) }} + {% with %} + {% set client_id_key_name = "SOCIAL_AUTH_" + social_backend_name.upper() + "_KEY" %} + {% include "zerver/authentication_backends/" + social_backend_name + "-error.html" %} + {% endwith %}

For more information, have a look at our authentication diff --git a/templates/zerver/dev-not-supported-error.md b/templates/zerver/dev-not-supported-error.md deleted file mode 100644 index 71a1ced31d..0000000000 --- a/templates/zerver/dev-not-supported-error.md +++ /dev/null @@ -1,11 +0,0 @@ -You attempted to use the `DevAuthBackend` authentication method, which -is used for logging in without a password in the Zulip development -environment. - -This backend is not available for this realm, either because: - -* This Zulip server is configured as a production server. -* `DevAuthBackend` is disabled in `AUTHENTICATION_BACKENDS` in `{{ -settings_path }}`. -* You disabled this authentication backend in [this realm's - authentication settings](/help/configure-authentication-methods). diff --git a/templates/zerver/github-error.md b/templates/zerver/github-error.md deleted file mode 100644 index 24fad50705..0000000000 --- a/templates/zerver/github-error.md +++ /dev/null @@ -1,12 +0,0 @@ -You are attempting to use the **GitHub auth backend**, but it is not -properly configured. To configure, please check the following: - -* You have added `{{ root_domain_uri }}/complete/github/` as the callback URL -in the OAuth application in GitHub. You can create OAuth apps from -[GitHub's developer site](https://github.com/settings/developers). - -* You have set `{{ client_id_key_name }}` in `{{ settings_path }}` and -`social_auth_github_secret` in `{{ secrets_path }}` with the values -from your OAuth application. - -* Navigate back to the login page and attempt the GitHub auth flow again. diff --git a/templates/zerver/gitlab-error.md b/templates/zerver/gitlab-error.md deleted file mode 100644 index ea4a121d9c..0000000000 --- a/templates/zerver/gitlab-error.md +++ /dev/null @@ -1,12 +0,0 @@ -You are attempting to use the **GitLab auth backend**, but it is not -properly configured. To configure, please check the following: - -* You have added `{{ root_domain_uri }}/complete/gitlab/` as the callback -URL in the OAuth application in GitLab. You can register OAuth apps at -[GitLab applications](https://gitlab.com/profile/applications). - -* You have set `{{ client_id_key_name }}` in `{{ settings_path }}` and -`social_auth_gitlab_secret` in `{{ secrets_path }}` with the values -from your OAuth application. - -* Navigate back to the login page and attempt the GitLab auth flow again. diff --git a/templates/zerver/google-error.md b/templates/zerver/google-error.md deleted file mode 100644 index 630dc05712..0000000000 --- a/templates/zerver/google-error.md +++ /dev/null @@ -1,13 +0,0 @@ -You are attempting to use the **Google auth backend**, but it is not -properly configured. To configure, please check the following: - -* You have created a Google OAuth2 client and enabled the Identity Toolkit API. -You can create OAuth2 apps at [the Google developer console](https://console.developers.google.com). - -* You have configured your OAuth2 client to allow redirects to your -server's Google auth URL: `{{ root_domain_uri }}/complete/google/`. - -* You have set `{{ client_id_key_name }}` in `{{ settings_path }}` and -`social_auth_google_secret` in `{{ secrets_path }}`. - -* Navigate back to the login page and attempt the Google auth flow again. diff --git a/zerver/views/auth.py b/zerver/views/auth.py index 67a6732a3b..6613bc1aa7 100644 --- a/zerver/views/auth.py +++ b/zerver/views/auth.py @@ -1128,10 +1128,10 @@ def saml_sp_metadata(request: HttpRequest) -> HttpResponse: # nocoverage def config_error(request: HttpRequest, error_category_name: str) -> HttpResponse: contexts: Dict[str, Dict[str, object]] = { - "apple": {"social_backend_name": "apple", "has_markdown_file": True}, - "google": {"social_backend_name": "google", "has_markdown_file": True}, - "github": {"social_backend_name": "github", "has_markdown_file": True}, - "gitlab": {"social_backend_name": "gitlab", "has_markdown_file": True}, + "apple": {"social_backend_name": "apple", "has_error_template": True}, + "google": {"social_backend_name": "google", "has_error_template": True}, + "github": {"social_backend_name": "github", "has_error_template": True}, + "gitlab": {"social_backend_name": "gitlab", "has_error_template": True}, "ldap": {"error_name": "ldap_error_realm_is_none"}, "dev": {"error_name": "dev_not_supported_error"}, "saml": {"social_backend_name": "saml"},