templates: Convert config errors to HTML.

Markdown and Jinja don’t mix correctly, and templating is not an
appropriate use of Markdown.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-02-28 10:56:58 -08:00 committed by Tim Abbott
parent ae089da9cb
commit 738667b39e
12 changed files with 134 additions and 77 deletions

View File

@ -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.

View File

@ -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 Apples developer console. You can enable “Sign
in with Apple” for an app at
<a href="https://developer.apple.com/account/resources/">Certificates,
Identifiers &amp; 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>

View File

@ -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 realms
authentication settings</a>.
</li>
</ul>

View File

@ -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">GitHubs 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>

View File

@ -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>

View File

@ -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
servers 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>

View File

@ -48,23 +48,26 @@
{% endif %} {% endif %}
{% if error_name == "dev_not_supported_error" %} {% 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 %} {% endif %}
{% if has_markdown_file %} {% if has_error_template %}
{% if development_environment %} {% if development_environment %}
{{ render_markdown_path('zerver/'+social_backend_name+'-error.md', {% with %}
{"root_domain_uri": root_domain_uri, "settings_path": secrets_path, "secrets_path": secrets_path, {% set settings_path = secrets_path %}
"client_id_key_name": "social_auth_" + social_backend_name + "_key"}) }} {% set client_id_key_name = "social_auth_" + social_backend_name + "_key" %}
{% include "zerver/authentication_backends/" + social_backend_name + "-error.html" %}
{% endwith %}
<p> <p>
For more information, have a look at For more information, have a look at
the <a href="https://zulip.readthedocs.io/en/latest/development/authentication.html#{{ social_backend_name }}">authentication the <a href="https://zulip.readthedocs.io/en/latest/development/authentication.html#{{ social_backend_name }}">authentication
setup guide</a> for the development environment. setup guide</a> for the development environment.
</p> </p>
{% else %} {% else %}
{{ render_markdown_path('zerver/'+social_backend_name+'-error.md', {% with %}
{"root_domain_uri": root_domain_uri, "settings_path": settings_path, "secrets_path": secrets_path, {% set client_id_key_name = "SOCIAL_AUTH_" + social_backend_name.upper() + "_KEY" %}
"client_id_key_name": "SOCIAL_AUTH_" + social_backend_name.upper() + "_KEY"}) }} {% include "zerver/authentication_backends/" + social_backend_name + "-error.html" %}
{% endwith %}
<p> <p>
For more information, have a look at For more information, have a look at
our <a href="https://zulip.readthedocs.io/en/latest/production/authentication-methods.html">authentication our <a href="https://zulip.readthedocs.io/en/latest/production/authentication-methods.html">authentication

View File

@ -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).

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -1128,10 +1128,10 @@ def saml_sp_metadata(request: HttpRequest) -> HttpResponse: # nocoverage
def config_error(request: HttpRequest, error_category_name: str) -> HttpResponse: def config_error(request: HttpRequest, error_category_name: str) -> HttpResponse:
contexts: Dict[str, Dict[str, object]] = { contexts: Dict[str, Dict[str, object]] = {
"apple": {"social_backend_name": "apple", "has_markdown_file": True}, "apple": {"social_backend_name": "apple", "has_error_template": True},
"google": {"social_backend_name": "google", "has_markdown_file": True}, "google": {"social_backend_name": "google", "has_error_template": True},
"github": {"social_backend_name": "github", "has_markdown_file": True}, "github": {"social_backend_name": "github", "has_error_template": True},
"gitlab": {"social_backend_name": "gitlab", "has_markdown_file": True}, "gitlab": {"social_backend_name": "gitlab", "has_error_template": True},
"ldap": {"error_name": "ldap_error_realm_is_none"}, "ldap": {"error_name": "ldap_error_realm_is_none"},
"dev": {"error_name": "dev_not_supported_error"}, "dev": {"error_name": "dev_not_supported_error"},
"saml": {"social_backend_name": "saml"}, "saml": {"social_backend_name": "saml"},