Projet

Général

Profil

Télécharger (5,99 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / univnautes / sp / sp / settings.py @ b1e68a2c

1
# Django settings for sp project.
2

    
3
import os
4
import pfconfigxml
5
from django.conf import global_settings
6

    
7
PROJECT_PATH = os.path.dirname(os.path.dirname(__file__))
8

    
9
DEBUG = False
10
TEMPLATE_DEBUG = DEBUG
11

    
12
# fastcgi (see http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/)
13
FORCE_SCRIPT_NAME=''
14

    
15
ADMINS = (
16
    # ('Your Name', 'your_email@example.com'),
17
)
18
MANAGERS = ADMINS
19

    
20
DATABASES = {
21
    'default': {
22
        'ENGINE': 'django.db.backends.sqlite3',
23
        'NAME': '/var/db/univnautes-sp.sqlite3',
24
    }
25
}
26

    
27
# Hosts/domain names that are valid for this site; required if DEBUG is False
28
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
29
ALLOWED_HOSTS = ['*']
30

    
31
# Local time zone for this installation. Choices can be found here:
32
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
33
# although not all choices may be available on all operating systems.
34
# In a Windows environment this must be set to your system time zone.
35
TIME_ZONE = 'Europe/Paris'
36

    
37
# Language code for this installation. All choices can be found here:
38
# http://www.i18nguy.com/unicode/language-identifiers.html
39
LANGUAGE_CODE = 'fr-fr'
40

    
41
SITE_ID = 1
42

    
43
# If you set this to False, Django will make some optimizations so as not
44
# to load the internationalization machinery.
45
USE_I18N = True
46

    
47
# If you set this to False, Django will not format dates, numbers and
48
# calendars according to the current locale.
49
USE_L10N = True
50

    
51
# If you set this to False, Django will not use timezone-aware datetimes.
52
USE_TZ = True
53

    
54
# Absolute filesystem path to the directory that will hold user-uploaded files.
55
# Example: "/var/www/example.com/media/"
56
MEDIA_ROOT = ''
57

    
58
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
59
# trailing slash.
60
# Examples: "http://example.com/media/", "http://media.example.com/"
61
MEDIA_URL = ''
62

    
63
# Absolute path to the directory static files should be collected to.
64
# Don't put anything in this directory yourself; store your static files
65
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
66
# Example: "/var/www/example.com/static/"
67
STATIC_ROOT = ''
68

    
69
# URL prefix for static files.
70
# Example: "http://example.com/static/", "http://static.example.com/"
71
STATIC_URL = '/static/'
72

    
73
# Additional locations of static files
74
STATICFILES_DIRS = (
75
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
76
    # Always use forward slashes, even on Windows.
77
    # Don't forget to use absolute paths, not relative paths.
78
)
79

    
80
# List of finder classes that know how to find static files in
81
# various locations.
82
STATICFILES_FINDERS = (
83
    'django.contrib.staticfiles.finders.FileSystemFinder',
84
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
85
)
86

    
87
# Make this unique, and don't share it with anybody.
88
SECRET_KEY_FILENAME='/usr/local/univnautes/sp/secret.key'
89
try:
90
    with open(SECRET_KEY_FILENAME, 'rb') as sk:
91
        SECRET_KEY = sk.read()
92
except IOError:
93
    import random, string
94
    SECRET_KEY = "".join([random.SystemRandom().choice(string.digits + string.letters + string.punctuation) for i in range(100)])
95
    with open(SECRET_KEY_FILENAME, 'wb') as sk:
96
        sk.write(SECRET_KEY)
97

    
98
# List of callables that know how to import templates from various sources.
99
TEMPLATE_LOADERS = (
100
    'django.template.loaders.filesystem.Loader',
101
    'django.template.loaders.app_directories.Loader',
102
)
103

    
104
MIDDLEWARE_CLASSES = (
105
    'django.middleware.common.CommonMiddleware',
106
    'django.contrib.sessions.middleware.SessionMiddleware',
107
    'django.middleware.csrf.CsrfViewMiddleware',
108
    'django.contrib.auth.middleware.AuthenticationMiddleware',
109
    'django.contrib.messages.middleware.MessageMiddleware',
110
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
111
)
112

    
113
ROOT_URLCONF = 'sp.urls'
114

    
115
# Python dotted path to the WSGI application used by Django's runserver.
116
WSGI_APPLICATION = 'sp.wsgi.application'
117

    
118
TEMPLATE_DIRS = (
119
    os.path.join(PROJECT_PATH, 'sp', 'templates'),
120
)
121

    
122
INSTALLED_APPS = (
123
    'django.contrib.auth',
124
    'django.contrib.contenttypes',
125
    'django.contrib.sessions',
126
    'django.contrib.sites',
127
    'django.contrib.messages',
128
    'django.contrib.staticfiles',
129
    #'django.contrib.admin',
130
    'authentic2.idp',
131
    'authentic2.attribute_aggregator',
132
    'authentic2.saml',
133
    'authentic2.authsaml2',
134
)
135

    
136
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
137

    
138
SESSION_COOKIE_NAME = 'univnautes-sp-sessionid'
139
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
140
SESSION_FILE_PATH = '/var/tmp/univnautes-sp-sessions'
141
try:
142
    os.mkdir(SESSION_FILE_PATH)
143
except:
144
    pass
145

    
146
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
147

    
148
LOGIN_REDIRECT_URL = '/'
149

    
150

    
151
# logging configuration
152
# FIXME : syslog (freebsd -> /var/run/log) / local4 / debug
153
LOGGING = {
154
    'version': 1,
155
    'disable_existing_loggers': False,
156
    'handlers': {
157
    'tmpspfile': {
158
            'level': 'DEBUG',
159
            'class': 'logging.FileHandler',
160
            'filename': '/tmp/sp.log'
161
    },
162
    },
163
    'loggers': {
164
        'django.request': {
165
            'handlers': ['tmpspfile'],
166
            'level': 'DEBUG',
167
            'propagate': True,
168
        },
169
    }
170
}
171

    
172
# authentic2 settings (SP)
173
LOCAL_METADATA_CACHE_TIMEOUT = 600
174
SAML_METADATA_ROOT = 'metadata'
175
SAML_METADATA_AUTOLOAD = 'none'
176

    
177
AUTH_FRONTENDS = ('authentic2.authsaml2.frontend.AuthSAML2Frontend',)
178
AUTHENTICATION_BACKENDS = (
179
        'django.contrib.auth.backends.ModelBackend',
180
        'authentic2.authsaml2.backends.AuthSAML2PersistentBackend',
181
        'authentic2.authsaml2.backends.AuthSAML2TransientBackend')
182

    
183

    
184
# get some values from config.xml
185
# => server must be restarted if config.xml is changed
186

    
187
sp = pfconfigxml.get_sp()
188
# SAML certificate
189
SAML_SIGNATURE_PUBLIC_KEY = sp.get('saml_cert', {}).get('crt')
190
SAML_SIGNATURE_PRIVATE_KEY = sp.get('saml_cert', {}).get('prv')
191

    
192
# SESSION_COOKIE_AGE from pfsenseid, at least 2 minutes
193
SESSION_COOKIE_AGE = max(sp.get('cp', {}).get('idletimeout', 2)*60, 2*60)
194

    
195
# SP User Interface parameters
196
SP_UI = sp.get('ui', {})
197
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
198
    'sp.context_processors.sp',
199
    )
200

    
(4-4/7)