1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# vim:fileencoding=utf8:et:ts=4:sts=4:sw=4:ft=python
# Django settings for okupy project.
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS
import os
# Full path of the project dir
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) + '/../..'
try:
from .local import *
except ImportError:
raise Exception('No settings/local.py found, please copy settings/local.py.sample and edit it accordingly')
if DEVELOPMENT:
try:
from .development import *
except ImportError:
raise Exception('No settings/development.py found, please copy settings/development.py.sample and edit it accordingly if needed')
else:
from .production import *
MANAGERS = ADMINS
SITE_ID = 1
ROOT_URLCONF = 'okupy.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'okupy.wsgi.application'
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'okupy': {
'format': '%(instance_name)s: %(levelname)s %(id_name)s %(client_ip)s Message: %(message)s File: %(module)s Function: %(funcName)s Line: %(lineno)d',
},
'django_auth_ldap': {
'format': 'django-auth-ldap: %(levelname)s Message: %(message)s',
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler',
'include_html': True,
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'okupy',
},
'syslog': {
'level': 'INFO',
'class': 'logging.handlers.SysLogHandler',
'formatter': 'okupy',
'address': '/dev/log',
},
'dlaconsole': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'django_auth_ldap',
},
'dlasyslog': {
'level': 'INFO',
'class': 'logging.handlers.SysLogHandler',
'formatter': 'django_auth_ldap',
'address': '/dev/log',
},
},
'loggers': {
'mail_okupy': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'okupy': {
'handlers': ['console' if DEBUG else 'syslog'],
'level': 'DEBUG' if DEBUG else 'INFO',
},
'django_auth_ldap': {
'handlers': ['dlaconsole' if DEBUG else 'dlasyslog'],
'level': 'DEBUG' if DEBUG else 'INFO',
},
}
}
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
LOGOUT_URL = '/logout/'
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
AUTH_LDAP_USER_DN_TEMPLATE = AUTH_LDAP_USER_ATTR + '=%(user)s,' + AUTH_LDAP_USER_BASE_DN
# Custom authentication backend
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
# email sending variables regarding server authentication
# and configuration should be specified in settings/local.py
EMAIL_SUBJECT_PREFIX = '[%s]: ' % INSTANCE_NAME
|