Easy override for social logins (#446)

Add MAILMAN_WEB_SOCIAL_AUTH for social logins

The `MAILMAN_WEB_SOCIAL_AUTH` list contains a default set of social
login provides. This was previously included in `INSTALLED_APPS`.

Separating it to it's own list makes it easier to disable or otherwise
override which social login providers are enabled without the need to
modify `INSTALLED_APPS`.

Older installations where `INSTALLED_APPS` were overridden continues to
work. The `MAILMAN_WEB_SOCIAL_AUTH` is ignored for those and
`INSTALLED_APPS` is used as is.
This commit is contained in:
Stefan Gangefors
2021-03-20 18:28:54 +01:00
committed by GitHub
parent 7d67045280
commit 47f70d73bd
3 changed files with 24 additions and 12 deletions

View File

@@ -66,7 +66,8 @@ MAILMAN_ARCHIVER_FROM = (os.environ.get('MAILMAN_HOST_IP', gethostbyname(os.envi
# Application definition
INSTALLED_APPS = [
INSTALLED_APPS = []
DEFAULT_APPS = [
'hyperkitty',
'postorius',
'django_mailman3',
@@ -89,6 +90,8 @@ INSTALLED_APPS = [
'allauth',
'allauth.account',
'allauth.socialaccount',
]
MAILMAN_WEB_SOCIAL_AUTH = [
'django_mailman3.lib.auth.fedora',
'allauth.socialaccount.providers.openid',
'allauth.socialaccount.providers.github',
@@ -96,16 +99,6 @@ INSTALLED_APPS = [
'allauth.socialaccount.providers.google',
]
# Optionally include paintstore, if it was installed with Hyperkitty.
# TODO: Remove this after a new version of Hyperkitty is released and
# neither the stable nor the rolling version needs it.
try:
import paintstore
INSTALLED_APPS.append('paintstore')
except ImportError:
pass
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
@@ -412,3 +405,7 @@ try:
from settings_local import *
except ImportError:
pass
# Compatibility for older installs that override INSTALLED_APPS
if not INSTALLED_APPS:
INSTALLED_APPS = DEFAULT_APPS + MAILMAN_WEB_SOCIAL_AUTH