Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
templates: Convert config errors to HTML.
Anders Kaseorg738667b39e7c
diff --git a/templates/zerver/apple-error.md b/templates/zerver/apple-error.mddeleted file mode 100644index c5de799fd08..00000000000--- 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.htmlnew file mode 100644index 00000000000..eb8bfd5c345--- /dev/null+++ b/templates/zerver/authentication_backends/apple-error.html@@ -0,0 +1,28 @@+<p>+ You are attempting to use the <strong>Apple auth backend</strong>, but it is+ not properly configured. To configure, please check the following:+</p>+<ul>+ <li>+ You have registered+ <code>{{ root_domain_uri }}/complete/apple/</code> as the callback URL+ for your Services ID in Apple’s developer console. You can enable “Sign+ in with Apple” for an app at+ <a href="https://developer.apple.com/account/resources/">Certificates,+ Identifiers & Profiles</a>.+ </li>+ <li>+ You have set <code>SOCIAL_AUTH_APPLE_SERVICES_ID</code>,+ <code>SOCIAL_AUTH_APPLE_APP_ID</code>,+ <code>SOCIAL_AUTH_APPLE_TEAM</code>, and+ <code>SOCIAL_AUTH_APPLE_KEY</code> in+ <code>{{ settings_path }}</code>+ and stored the private key provided by Apple at+ <code>/etc/zulip/apple-auth-key.p8</code> on the Zulip server, with+ proper permissions set.+ </li>+ <li>+ Navigate back to the login page and attempt the “Sign in with Apple”+ flow again.+ </li>+</ul>diff --git a/templates/zerver/authentication_backends/dev-not-supported-error.html b/templates/zerver/authentication_backends/dev-not-supported-error.htmlnew file mode 100644index 00000000000..a41487b7e54--- /dev/null+++ b/templates/zerver/authentication_backends/dev-not-supported-error.html@@ -0,0 +1,19 @@+<p>+ You attempted to use the <code>DevAuthBackend</code> authentication method,+ which is used for logging in without a password in the Zulip development+ environment.+</p>+<p>This backend is not available for this realm, either because:</p>+<ul>+ <li>This Zulip server is configured as a production server.</li>+ <li>+ <code>DevAuthBackend</code> is disabled in+ <code>AUTHENTICATION_BACKENDS</code> in+ <code>{{ settings_path }}</code>.+ </li>+ <li>+ You disabled this authentication backend in+ <a href="/help/configure-authentication-methods">this realm’s+ authentication settings</a>.+ </li>+</ul>diff --git a/templates/zerver/authentication_backends/github-error.html b/templates/zerver/authentication_backends/github-error.htmlnew file mode 100644index 00000000000..1055a63f0d8--- /dev/null+++ b/templates/zerver/authentication_backends/github-error.html@@ -0,0 +1,23 @@+<p>+ You are attempting to use the <strong>GitHub auth backend</strong>, but it+ is not properly configured. To configure, please check the following:+</p>+<ul>+ <li>+ You have added+ <code>{{ root_domain_uri }}/complete/github/</code> as the callback URL+ in the OAuth application in GitHub. You can create OAuth apps from+ <a href="https://github.com/settings/developers">GitHub’s developer+ site</a>.+ </li>+ <li>+ You have set <code>{{ client_id_key_name }}</code> in+ <code>{{ settings_path }}</code> and+ <code>social_auth_github_secret</code> in+ <code>{{ secrets_path }}</code> with the values from your OAuth+ application.+ </li>+ <li>+ Navigate back to the login page and attempt the GitHub auth flow again.+ </li>+</ul>diff --git a/templates/zerver/authentication_backends/gitlab-error.html b/templates/zerver/authentication_backends/gitlab-error.htmlnew file mode 100644index 00000000000..69bd00893c4--- /dev/null+++ b/templates/zerver/authentication_backends/gitlab-error.html@@ -0,0 +1,23 @@+<p>+ You are attempting to use the <strong>GitLab auth backend</strong>, but it+ is not properly configured. To configure, please check the following:+</p>+<ul>+ <li>+ You have added+ <code>{{ root_domain_uri }}/complete/gitlab/</code> as the callback URL+ in the OAuth application in GitLab. You can register OAuth apps at+ <a href="https://gitlab.com/profile/applications">GitLab+ applications</a>.+ </li>+ <li>+ You have set <code>{{ client_id_key_name }}</code> in+ <code>{{ settings_path }}</code> and+ <code>social_auth_gitlab_secret</code> in+ <code>{{ secrets_path }}</code> with the values from your OAuth+ application.+ </li>+ <li>+ Navigate back to the login page and attempt the GitLab auth flow again.+ </li>+</ul>diff --git a/templates/zerver/authentication_backends/google-error.html b/templates/zerver/authentication_backends/google-error.htmlnew file mode 100644index 00000000000..2d441a97c08--- /dev/null+++ b/templates/zerver/authentication_backends/google-error.html@@ -0,0 +1,26 @@+<p>+ You are attempting to use the <strong>Google auth backend</strong>, but it+ is not properly configured. To configure, please check the following:+</p>+<ul>+ <li>+ You have created a Google OAuth2 client and enabled the Identity Toolkit+ API. You can create OAuth2 apps at+ <a href="https://console.developers.google.com">the Google developer+ console</a>.+ </li>+ <li>+ You have configured your OAuth2 client to allow redirects to your+ server’s Google auth URL:+ <code>{{ root_domain_uri }}/complete/google/</code>.+ </li>+ <li>+ You have set <code>{{ client_id_key_name }}</code> in+ <code>{{ settings_path }}</code> and+ <code>social_auth_google_secret</code> in+ <code>{{ secrets_path }}</code>.+ </li>+ <li>+ Navigate back to the login page and attempt the Google auth flow again.+ </li>+</ul>diff --git a/templates/zerver/config_error.html b/templates/zerver/config_error.htmlindex a2cbe824cd9..dd3745686fb 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 %}<p>For more information, have a look atthe <a href="https://zulip.readthedocs.io/en/latest/development/authentication.html#{{ social_backend_name }}">authenticationsetup guide</a> for the development environment.</p>{% 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 %}<p>For more information, have a look atour <a href="https://zulip.readthedocs.io/en/latest/production/authentication-methods.html">authenticationdiff --git a/templates/zerver/dev-not-supported-error.md b/templates/zerver/dev-not-supported-error.mddeleted file mode 100644index 71a1ced31d6..00000000000--- 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.mddeleted file mode 100644index 24fad50705c..00000000000--- 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.mddeleted file mode 100644index ea4a121d9ca..00000000000--- 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.mddeleted file mode 100644index 630dc05712d..00000000000--- 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.pyindex 67a6732a3b6..6613bc1aa7a 100644--- a/zerver/views/auth.py+++ b/zerver/views/auth.py@@ -1128,10 +1128,10 @@ def saml_sp_metadata(request: HttpRequest) -> HttpResponse: # nocoveragedef 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"},