1
|
# mandayejs - saml reverse proxy
|
2
|
# Copyright (C) 2015 Entr'ouvert
|
3
|
#
|
4
|
# This program is free software: you can redistribute it and/or modify it
|
5
|
# under the terms of the GNU Affero General Public License as published
|
6
|
# by the Free Software Foundation, either version 3 of the License, or
|
7
|
# (at your option) any later version.
|
8
|
#
|
9
|
# This program is distributed in the hope that it will be useful,
|
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
# GNU Affero General Public License for more details.
|
13
|
#
|
14
|
# You should have received a copy of the GNU Affero General Public License
|
15
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
|
17
|
"""
|
18
|
Django settings for mandayejs project.
|
19
|
|
20
|
For more information on this file, see
|
21
|
https://docs.djangoproject.com/en/1.7/topics/settings/
|
22
|
|
23
|
For the full list of settings and their values, see
|
24
|
https://docs.djangoproject.com/en/1.7/ref/settings/
|
25
|
"""
|
26
|
|
27
|
from django.conf import global_settings
|
28
|
|
29
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
30
|
import os
|
31
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
32
|
|
33
|
|
34
|
# Quick-start development settings - unsuitable for production
|
35
|
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
36
|
|
37
|
# SECURITY WARNING: keep the secret key used in production secret!
|
38
|
SECRET_KEY = 'xlf$@r5j*6p5-l#q=bg&t$mlhf=v@fq9^xfs#%712zndtu2#2@'
|
39
|
|
40
|
# SECURITY WARNING: don't run with debug turned on in production!
|
41
|
DEBUG = True
|
42
|
|
43
|
ALLOWED_HOSTS = []
|
44
|
|
45
|
|
46
|
# Application definition
|
47
|
|
48
|
INSTALLED_APPS = (
|
49
|
'django.contrib.admin',
|
50
|
'django.contrib.auth',
|
51
|
'django.contrib.contenttypes',
|
52
|
'django.contrib.sessions',
|
53
|
'django.contrib.messages',
|
54
|
'django.contrib.staticfiles',
|
55
|
'rest_framework',
|
56
|
'mandayejs',
|
57
|
'mandayejs.mandaye',
|
58
|
'gadjo',
|
59
|
'mellon'
|
60
|
)
|
61
|
|
62
|
MIDDLEWARE_CLASSES = (
|
63
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
64
|
'django.middleware.common.CommonMiddleware',
|
65
|
'django.middleware.csrf.CsrfViewMiddleware',
|
66
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
67
|
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
|
68
|
'django.contrib.messages.middleware.MessageMiddleware',
|
69
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
70
|
'django.middleware.locale.LocaleMiddleware',
|
71
|
)
|
72
|
|
73
|
ROOT_URLCONF = 'mandayejs.urls'
|
74
|
|
75
|
WSGI_APPLICATION = 'mandayejs.wsgi.application'
|
76
|
|
77
|
|
78
|
# Database
|
79
|
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
|
80
|
|
81
|
DATABASES = {
|
82
|
'default': {
|
83
|
'ENGINE': 'django.db.backends.sqlite3',
|
84
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
85
|
}
|
86
|
}
|
87
|
|
88
|
# Internationalization
|
89
|
# https://docs.djangoproject.com/en/1.7/topics/i18n/
|
90
|
|
91
|
LANGUAGE_CODE = 'fr'
|
92
|
|
93
|
TIME_ZONE = 'UTC'
|
94
|
|
95
|
USE_I18N = True
|
96
|
|
97
|
USE_L10N = True
|
98
|
|
99
|
USE_TZ = True
|
100
|
|
101
|
LANGUAGES = (
|
102
|
('fr', 'Francais'),
|
103
|
)
|
104
|
|
105
|
LOCALE_PATHS = (
|
106
|
os.path.join(BASE_DIR, 'mandayejs/locale'),
|
107
|
)
|
108
|
|
109
|
# Static files (CSS, JavaScript, Images)
|
110
|
# https://docs.djangoproject.com/en/1.7/howto/static-files/
|
111
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
112
|
|
113
|
STATIC_URL = '/_mandaye/static/'
|
114
|
|
115
|
# Serve xstatic files, required for gadjo
|
116
|
STATICFILES_FINDERS = list(global_settings.STATICFILES_FINDERS) + \
|
117
|
['gadjo.finders.XStaticFinder']
|
118
|
|
119
|
STATIC_DIRS = (
|
120
|
os.path.join(BASE_DIR, 'static'),
|
121
|
)
|
122
|
|
123
|
TEMPLATES = [
|
124
|
{
|
125
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
126
|
'APP_DIRS': True,
|
127
|
'DIRS': [],
|
128
|
'OPTIONS': {
|
129
|
'context_processors': [
|
130
|
'django.contrib.auth.context_processors.auth',
|
131
|
'django.template.context_processors.debug',
|
132
|
'django.template.context_processors.i18n',
|
133
|
'django.template.context_processors.media',
|
134
|
'django.template.context_processors.static',
|
135
|
'django.template.context_processors.tz',
|
136
|
'django.contrib.messages.context_processors.messages',
|
137
|
'django.template.context_processors.request',
|
138
|
],
|
139
|
},
|
140
|
},
|
141
|
]
|
142
|
|
143
|
|
144
|
LOGIN_URL = 'mellon_login'
|
145
|
LOGIN_LOGOUT = 'mellon_logout'
|
146
|
LOGIN_REDIRECT_URL = 'home'
|
147
|
|
148
|
# Authentication settings
|
149
|
try:
|
150
|
import mellon
|
151
|
except ImportError:
|
152
|
mellon = None
|
153
|
|
154
|
if mellon is not None:
|
155
|
AUTHENTICATION_BACKENDS = (
|
156
|
'mellon.backends.SAMLBackend',
|
157
|
'django.contrib.auth.backends.ModelBackend',
|
158
|
)
|
159
|
|
160
|
MELLON_ATTRIBUTE_MAPPING = {
|
161
|
'email': '{attributes[email][0]}',
|
162
|
'first_name': '{attributes[first_name][0]}',
|
163
|
'last_name': '{attributes[last_name][0]}',
|
164
|
}
|
165
|
|
166
|
MELLON_SUPERUSER_MAPPING = {
|
167
|
'is_superuser': 'true'
|
168
|
}
|
169
|
|
170
|
MELLON_USERNAME_TEMPLATE = '{attributes[name_id_content]}'
|
171
|
|
172
|
MELLON_IDENDITY_PROVIDERS = []
|
173
|
|
174
|
REST_FRAMEWORK = {
|
175
|
'DEFAULT_PERMISSION_CLASSES' : (
|
176
|
'rest_framework.permissions.IsAuthenticated',
|
177
|
)
|
178
|
}
|
179
|
|
180
|
# AppSettings Class to use
|
181
|
# example : 'mandayejs.applications.MyApp'
|
182
|
SITE_APP = None
|
183
|
|
184
|
PHANTOM_JS_BINARY = '/usr/bin/phantomjs'
|
185
|
|
186
|
# Default timeout before killing Phantomjs process
|
187
|
PHANTOM_JS_TIMEOUT = 10
|
188
|
|
189
|
# Scheme to use for phantomjs logout
|
190
|
PHANTOM_JS_LOGOUT_SCHEME = None # Default is request scheme
|
191
|
|
192
|
JSONFIELD_ENCODER_CLASS = 'django.core.serializers.json.DjangoJSONEncoder'
|
193
|
|
194
|
# adjust environment for phantomjs
|
195
|
os.environ['QT_QPA_PLATFORM'] = 'offscreen'
|
196
|
os.environ['QT_QPA_FONTDIR'] = '/usr/share/fonts'
|
197
|
|
198
|
|
199
|
local_settings_file = os.environ.get('MANDAYEJS_SETTINGS_FILE',
|
200
|
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
|
201
|
if os.path.exists(local_settings_file):
|
202
|
exec(open(local_settings_file).read())
|