mailman3: re-sync custom web/settings.py

The version in the container config repository has moved on, update
our copy with overrides for the allowed hosts and site ID. Adjust
how we generate the allowed hosts envvar list to replace Exim's
field separators with those expected by Mailman.

Change-Id: Ia6831ca10e1cd1ad057475e0f78eacc02857eef2
This commit is contained in:
Jeremy Stanley
2023-08-25 20:41:13 +00:00
parent c9c8febd84
commit e13ea50e68
2 changed files with 9 additions and 20 deletions

View File

@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
#
# This file has been copied from:
# https://github.com/maxking/docker-mailman/blob/2693386453ff3865b7c106c6aa456b683bd3bf08/web/mailman-web/settings.py
# https://github.com/maxking/docker-mailman/blob/57a2f54/web/mailman-web/settings.py
# In order to override the ALLOWED_HOSTS and SITE_ID settings.
#
# -*- coding: utf-8 -*-
# Copyright (C) 1998-2016 by the Free Software Foundation, Inc.
#
# This file is part of Mailman Suite.
@@ -54,24 +55,12 @@ SITE_ID = 0
# See https://docs.djangoproject.com/en/3.1/ref/settings/#allowed-hosts
ALLOWED_HOSTS = [
"localhost", # Archiving API from Mailman, keep it.
"127.0.0.1", # Archiving API from Mailman, keep it. OpenDev edit
# "lists.your-domain.org",
# Add here all production URLs you may have.
# The next two entries are commented out to prevent name resolution
# problems. This is an opendev local edit.
# Note we cannot use settings_local.py as this entry is evaluated at
# import time.
#"mailman-web",
#gethostbyname("mailman-web"),
"127.0.0.1", # OpenDev addition because we use host networking
#"mailman-web", # OpenDev edit, won't resolve for us
#gethostbyname("mailman-web"), # OpenDev edit, won't resolve for us
os.environ.get('SERVE_FROM_DOMAIN'),
#os.environ.get('DJANGO_ALLOWED_HOSTS'),
]
# We have modified handling of DJANGO_ALLOWED_HOSTS here to deserialize a
# list of hosts into a python list of strings.
django_allowed_hosts = os.environ.get('DJANGO_ALLOWED_HOSTS')
if django_allowed_hosts:
ALLOWED_HOSTS.extend(django_allowed_hosts.split(':'))
ALLOWED_HOSTS.extend(os.getenv("DJANGO_ALLOWED_HOSTS", "").split(","))
# Mailman API credentials
MAILMAN_REST_API_URL = os.environ.get('MAILMAN_REST_URL', 'http://mailman-core:8001')
@@ -194,7 +183,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
TIME_ZONE = os.environ.get('TZ', 'UTC')
USE_I18N = True

View File

@@ -41,7 +41,7 @@ services:
#- MAILMAN_ADMIN_USER={{ mailman3_admin_user }}
#- MAILMAN_ADMIN_EMAIL={{ mailman3_admin_email }}
- SERVE_FROM_DOMAIN=lists.opendev.org
- DJANGO_ALLOWED_HOSTS={{ mm_domains }}
- DJANGO_ALLOWED_HOSTS={{ mm_domains.split(':') | join(',') }}
- DATABASE_TYPE=mysql
- DATABASE_URL=mysql://mailman:{{ mailman3_db_password }}@127.0.0.1:3306/mailmandb?charset=utf8mb4
- HYPERKITTY_API_KEY={{ mailman3_hyperkitty_api_key }}