From 61ac52cf4ecec1b263beb55a007ebbd59887b689 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Mon, 17 Feb 2020 12:37:48 +0100 Subject: [PATCH] Disable the social auth providers by default: they must be configured before being put in use. --- defaults/main.yml | 14 +++++++++++++- templates/postorious_settings.py.j2 | 21 ++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 6a939cf..ef92ce8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,10 +13,22 @@ mailman_site_owner: 'mailman@example.com' mailman_from_email: 'mailman@example.com' mailman_server_email: 'mailman@example.com' mailman_noreply_addr: 'noreply' -mailman_use_social_account_providers: False mailman_use_memcache: False mailman_memcache_hosts: '127.0.0.1:11211' mailman_site_url: 'http://localhost' +# Documentation that must be followed to configure the social auth providers +# https://django-allauth.readthedocs.io/en/latest/installation.html +mailman_use_social_account_providers: False +mailman_postorious_social_auth_providers: + - 'django_mailman3.lib.auth.fedora' + - 'allauth.socialaccount.providers.openid' + - 'allauth.socialaccount.providers.github' + - 'allauth.socialaccount.providers.gitlab' + - 'allauth.socialaccount.providers.google' + - 'allauth.socialaccount.providers.facebook' + - 'allauth.socialaccount.providers.twitter' + - 'allauth.socialaccount.providers.stackexchange' + mailman_admins: - "'Mailman Suite Admin', 'mailman@example.com'" diff --git a/templates/postorious_settings.py.j2 b/templates/postorious_settings.py.j2 index 08a4230..dbc42d2 100644 --- a/templates/postorious_settings.py.j2 +++ b/templates/postorious_settings.py.j2 @@ -83,15 +83,13 @@ INSTALLED_APPS = ( 'django_q', 'allauth', 'allauth.account', - 'allauth.socialaccount', - 'django_mailman3.lib.auth.fedora', - 'allauth.socialaccount.providers.openid', - 'allauth.socialaccount.providers.github', - 'allauth.socialaccount.providers.gitlab', - 'allauth.socialaccount.providers.google', - # 'allauth.socialaccount.providers.facebook', - 'allauth.socialaccount.providers.twitter', - 'allauth.socialaccount.providers.stackexchange', + 'allauth.socialaccount' +{% if mailman_use_social_account_providers %} +{% for auth_provider in mailman_postorious_social_auth_providers %} + '{{ auth_privider }}', +{% endfor %} +{% endif %} + ) @@ -295,12 +293,12 @@ ACCOUNT_EMAIL_VERIFICATION = "mandatory" ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https" ACCOUNT_UNIQUE_EMAIL = True -{% if mailman_use_social_account_providers %} AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ) +{% if mailman_use_social_account_providers %} SOCIALACCOUNT_PROVIDERS = { 'openid': { 'SERVERS': [ @@ -328,9 +326,6 @@ SOCIALACCOUNT_PROVIDERS = { }, } {% else %} -AUTHENTICATION_BACKENDS = ( - 'django.contrib.auth.backends.ModelBackend', -) SOCIALACCOUNT_PROVIDERS = { } {% endif %}