Merge context processors

This commit is contained in:
shamoon 2023-10-01 09:48:03 -07:00
parent 7b1f9a089e
commit ec6e07887b
4 changed files with 10 additions and 10 deletions

View File

@ -5,4 +5,9 @@ def settings(request):
return { return {
"EMAIL_ENABLED": django_settings.EMAIL_HOST != "localhost" "EMAIL_ENABLED": django_settings.EMAIL_HOST != "localhost"
or django_settings.EMAIL_HOST_USER != "", or django_settings.EMAIL_HOST_USER != "",
"DISABLE_NORMAL_AUTH": django_settings.SOCIAL_AUTH_DISABLE_NORMAL_AUTH,
"OIDC_ENABLE": django_settings.SOCIAL_AUTH_OIDC_ENABLE,
"OIDC_NAME": django_settings.SOCIAL_AUTH_OIDC_NAME
if django_settings.SOCIAL_AUTH_OIDC_ENABLE
else None,
} }

View File

@ -52,7 +52,7 @@
{% translate "Share link has expired." %} {% translate "Share link has expired." %}
</div> </div>
{% endif %} {% endif %}
{% if not SOCIAL_AUTH_DISABLE_NORMAL_AUTH %} {% if not DISABLE_NORMAL_AUTH %}
{% translate "Username" as i18n_username %} {% translate "Username" as i18n_username %}
{% translate "Password" as i18n_password %} {% translate "Password" as i18n_password %}
<div class="form-floating"> <div class="form-floating">
@ -72,8 +72,8 @@
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if SOCIAL_AUTH_OIDC_ENABLE %} {% if OIDC_ENABLE %}
<a class="btn btn-lg btn-primary btn-block" href="{% url "social:begin" "oidc" %}">{{ SOCIAL_AUTH_OIDC_NAME }}</a> <a class="btn btn-lg btn-primary btn-block" href="{% url "social:begin" "oidc" %}">{{ OIDC_NAME }}</a>
{% endif %} {% endif %}
</form> </form>
</body> </body>

View File

@ -1,5 +0,0 @@
from django.conf import settings as django_settings
def settings(request):
return {"settings": django_settings}

View File

@ -389,8 +389,8 @@ AUTHENTICATION_BACKENDS = [
SOCIAL_AUTH_DISABLE_NORMAL_AUTH = __get_boolean("PAPERLESS_SSO_DISABLE_NORMAL_AUTH") SOCIAL_AUTH_DISABLE_NORMAL_AUTH = __get_boolean("PAPERLESS_SSO_DISABLE_NORMAL_AUTH")
# Only support OIDC, but it should be easy to enable more backends # Only support OIDC, but it should be easy to enable more backends
if __get_boolean("PAPERLESS_SSO_OIDC_ENABLE"): SOCIAL_AUTH_OIDC_ENABLE = __get_boolean("PAPERLESS_SSO_OIDC_ENABLE")
SOCIAL_AUTH_OIDC_ENABLE = True if SOCIAL_AUTH_OIDC_ENABLE:
AUTHENTICATION_BACKENDS.append( AUTHENTICATION_BACKENDS.append(
"social_core.backends.open_id_connect.OpenIdConnectAuth", "social_core.backends.open_id_connect.OpenIdConnectAuth",
) )