settings.py 8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
"""
Django settings for nm project.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

11
from django.utils.translation import gettext_lazy as _
12
from nm2.lib.log_utils import get_logging_config
13
from signon import providers
14
15
import os.path
import datetime
16
import sys
17

18
19
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Enrico Zini's avatar
Enrico Zini committed
20

21
22
# BASE_DIR is the default from newer djangos. PROJECT_DIR could still be used
# in developers settings, so it's kept here for a while
23
PROJECT_DIR = BASE_DIR
Enrico Zini's avatar
Enrico Zini committed
24

25
DATA_DIR = os.path.join(BASE_DIR, 'data')
Enrico Zini's avatar
Enrico Zini committed
26

27
28
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
Enrico Zini's avatar
Enrico Zini committed
29

30
# SECURITY WARNING: keep the secret key used in production secret!
31
SECRET_KEY = 'thisisnotreallysecretweonlyuseitfortestingharrharr'
Enrico Zini's avatar
Enrico Zini committed
32

33
34
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Enrico Zini's avatar
Enrico Zini committed
35

36
ALLOWED_HOSTS = []
Enrico Zini's avatar
Enrico Zini committed
37

38
TESTING = 'test' in sys.argv
Enrico Zini's avatar
Enrico Zini committed
39

40
# Application definition
Enrico Zini's avatar
Enrico Zini committed
41

42
INSTALLED_APPS = [
43
44
    'django.contrib.admin',
    'django.contrib.admindocs',
Enrico Zini's avatar
Enrico Zini committed
45
46
47
48
49
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
50
    'django.contrib.sites',
Enrico Zini's avatar
Enrico Zini committed
51
52
    # https://github.com/spanezz/django-housekeeping
    'django_housekeeping',
53
    'rest_framework',
54
    'legacy',
Enrico Zini's avatar
Enrico Zini committed
55
56
    'keyring',
    'dsa',
57
58
    'deblayout',
    'nmlayout',
59
    'backend',
Enrico Zini's avatar
Enrico Zini committed
60
    'apikeys',
61
    'person',
62
63
    'public',
    'restricted',
Enrico Zini's avatar
Enrico Zini committed
64
    'process',
65
    'fprs',
66
    'dm',
67
    'maintenance',
Enrico Zini's avatar
Enrico Zini committed
68
    'projectb',
Enrico Zini's avatar
Enrico Zini committed
69
    'minechangelogs',
70
    'api',
71
    'contributors',
72
    'wizard',
73
    'mia',
74
    'sitechecks',
Enrico Zini's avatar
Enrico Zini committed
75
    'deploy',
76
    'signon',
77
    'impersonate',
78
]
Enrico Zini's avatar
Enrico Zini committed
79

80
81
82
83
84
85
86
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
87
88
    # Needs to stay right after AuthenticationMiddleware
    'signon.middleware.SignonMiddleware',
89
90
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
91
    'impersonate.middleware.ImpersonateMiddleware',
92
93
94
]

AUTHENTICATION_BACKENDS = [
95
    'signon.middleware.SignonAuthBackend',
96
97
98
99
]

ROOT_URLCONF = 'nm2.urls'

Enrico Zini's avatar
Enrico Zini committed
100
101
102
103
104
105
106
107
108
109
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            "./", "templates"
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
110
111
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
Enrico Zini's avatar
Enrico Zini committed
112
113
114
115
116
                'django.template.context_processors.i18n',
                'django.template.context_processors.media',
                'django.template.context_processors.static',
                'django.template.context_processors.tz',
                'django.contrib.messages.context_processors.messages',
117
                'backend.context_processors.const',
Enrico Zini's avatar
Enrico Zini committed
118
119
120
            ],
        },
    },
Enrico Zini's avatar
Enrico Zini committed
121
]
Enrico Zini's avatar
Enrico Zini committed
122

123
# Database configuration for development environments
124
125
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

126
127
DATABASES = {
    'default': {
128
        'ENGINE': 'django.db.backends.sqlite3',
Enrico Zini's avatar
Enrico Zini committed
129
        'NAME': '%s/db-used-for-development.sqlite' % DATA_DIR,  # Or path to database file if using sqlite3.
130
131
132
133
134
135
    },
    'projectb': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'projectb',
        'USER': 'guest',
        'HOST': 'localhost',
136
        # ssh mirror.ftp-master.debian.org -N -L15434:bmdb1.debian.org:5434
137
        'PORT': '15434',                 # Port forwarded
Enrico Zini's avatar
Enrico Zini committed
138
        # 'PORT': '5433',                  # Local
139
140
141
142
143
144
145
146
147
    },
}
if TESTING:
    DATABASES["projectb"] = {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': '{}/test-projectb.sqlite'.format(DATA_DIR),
    }

# Prevent attempts to create tables on projectb (they would fail anyway)
148
149
DATABASE_ROUTERS = ["projectb.router.DbRouter"]

150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169

# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'

170
171
172
173
174
175
176
# Enable using system assets
from django.conf.global_settings import STATICFILES_DIRS # noqa
STATICFILES_DIRS += [
    ("common", "/usr/share/javascript/"),
]


177
ADMINS = (
178
    ('Debian New Member Front Desk', 'nm@debian.org'),
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
)
MANAGERS = ADMINS

DEFAULT_FROM_EMAIL = "nm@debian.org"
SERVER_EMAIL = "nm@debian.org"

LOCALE_PATHS = [os.path.join(PROJECT_DIR, "locale")]

LANGUAGES = (
    ('de', _('German')),
    ('en', _('English')),
    ('es', _('Spanish')),
    ('it', _('Italian')),
    ('fr', _('French')),
)


SITE_ID = 1


AUTH_USER_MODEL = 'backend.Person'


REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.AllowAny',
    ),
206
207
208
209
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.SessionAuthentication',
        'apikeys.authentication.ApiKeyAuthentication',
    ),
210
211
}

Enrico Zini's avatar
Enrico Zini committed
212

Enrico Zini's avatar
Enrico Zini committed
213
# LDAP server to use to access Debian's official LDAP information
Enrico Zini's avatar
Enrico Zini committed
214
LDAP_SERVER = "ldap://db.debian.org"
Enrico Zini's avatar
Enrico Zini committed
215

216
217
218
# Location of temporary keyrings used by keycheck
KEYRINGS_TMPDIR = os.path.join(DATA_DIR, "tmp_keyrings")

Enrico Zini's avatar
Enrico Zini committed
219
220
221
222
223
224
# Keyring used to validate signatures of keyring-maint members
KEYRING_MAINT_KEYRING = os.path.join(DATA_DIR, "keyring-maint.gpg")

# Git repository of keyring-maint's git repo
KEYRING_MAINT_GIT_REPO = os.path.join(DATA_DIR, "keyring-maint.git")

Enrico Zini's avatar
Enrico Zini committed
225
# Work paths used by minechangelogs (indexing cache and the index itself)
226
227
MINECHANGELOGS_CACHEDIR = os.path.join(DATA_DIR, "mc_cache")
MINECHANGELOGS_INDEXDIR = os.path.join(DATA_DIR, "mc_index")
228

Enrico Zini's avatar
Enrico Zini committed
229
# Directory where site backups are stored
Enrico Zini's avatar
Enrico Zini committed
230
HOUSEKEEPING_ROOT = os.path.join(DATA_DIR, "housekeeping")
Enrico Zini's avatar
Enrico Zini committed
231

Enrico Zini's avatar
Enrico Zini committed
232
233
# Directory where applicant mailboxes are stored
PROCESS_MAILBOX_DIR = os.path.join(DATA_DIR, "applicant-mailboxes")
234

235
236
237
# Directory where applicant mailboxes are stored for old-style processes
PROCESS_MAILBOX_DIR_OLD = os.path.join(DATA_DIR, "applicant-mailboxes")

Enrico Zini's avatar
Enrico Zini committed
238
# Date where we imported DM information that had no timestamp.
239
# DMs created on this date are in fact DMs created on an unknown date
240
DM_IMPORT_DATE = datetime.datetime(2012, 3, 14, tzinfo=datetime.timezone.utc)
241
242
243

# The password for this account is available from: master.debian.org:/home/debian/misc/rt-password
RT_LOGIN_INFO = {'user': "debian", 'pass': "the_guest_password"}
Ville Korhonen's avatar
Ville Korhonen committed
244

245
246
247
# Directory where email configuration is stored
MAIL_CONFDIR = "/srv/nm.debian.org/mail"

248
249
250
251
SIGNON_PROVIDERS = [
    providers.DebssoProvider(name="debsso", label="sso.debian.org"),
]

252
253
SIGNON_VIEW_MIXIN = "nmlayout.mixins.SignonMixin"

254
255
256
# Automatically bind unbound identifiers when active together with a bound one
SIGNON_AUTO_BIND = False

257
SIGNON_TEST_FIXTURE = "backend.unittest.SignonFixtureMixin"
258
IMPERSONATE_TEST_FIXTURE = "backend.unittest.ImpersonateFixtureMixin"
259

260
261
262
# Sync with this salsa host
SALSA_HOST = "https://salsa-test.debian.net"

263
264
265
# IPs to which we allow user information to be exported for Salsa
SALSA_EXPORT_ALLOW_IPS = []

266
267
268
# IPs to which we allow identity information to be exported for contributors.debian.org
IDENTITIES_EXPORT_ALLOW_IPS = []

269
270
271
# If set, the RT API calls when a process if approved won't be done and a mock id will be returned
MOCK_RT = False

272
273
274
# Mail address of the Community Team
COMMUNITY_EMAIL = "community@debian.org"

Ville Korhonen's avatar
Ville Korhonen committed
275
276
# Try importing local settings from local_settings.py, if we can't, it's just fine, use defaults from this file
try:
Enrico Zini's avatar
Enrico Zini committed
277
    from .local_settings import *  # noqa
278
except ImportError:
Ville Korhonen's avatar
Ville Korhonen committed
279
    pass
280
281

# Log to file on top of the normal django logging
282
LOGGING = get_logging_config(f"{DATA_DIR}/logs/django.log")