settings.py 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import ldap
  4. from django_auth_ldap.config import LDAPSearch, PosixGroupType
  5. # from custom.coin_posix_group_type import CoinPosixGroupType
  6. # Django settings for coin project.
  7. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  8. BASE_DIR = os.path.dirname(os.path.dirname(__file__))
  9. PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
  10. DEBUG = TEMPLATE_DEBUG = False
  11. ADMINS = (
  12. # ('Your Name', 'your_email@example.com'),
  13. )
  14. MANAGERS = ADMINS
  15. DATABASES = {
  16. # Base de donnée du SI
  17. 'default': {
  18. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  19. 'NAME': 'illyse_coin',
  20. 'USER': 'illyse_coin',
  21. 'PASSWORD': '',
  22. 'HOST': '', # Empty for localhost through domain sockets
  23. 'PORT': '', # Empty for default
  24. },
  25. # LDAP backend pour stockage et mise à jour de données
  26. 'ldap': {
  27. 'ENGINE': 'ldapdb.backends.ldap',
  28. 'NAME': 'ldap://ldapdev.illyse.org:390/',
  29. 'TLS': True,
  30. 'USER': 'cn=illysedev,ou=services,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR',
  31. 'PASSWORD': 'gfj83-E8ECgGh23JK_Ol12'
  32. }
  33. }
  34. DATABASE_ROUTERS = ['ldapdb.router.Router']
  35. # Hosts/domain names that are valid for this site; required if DEBUG is False
  36. # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
  37. ALLOWED_HOSTS = []
  38. # Local time zone for this installation. Choices can be found here:
  39. # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
  40. # although not all choices may be available on all operating systems.
  41. # In a Windows environment this must be set to your system time zone.
  42. TIME_ZONE = 'Europe/Paris'
  43. # Language code for this installation. All choices can be found here:
  44. # http://www.i18nguy.com/unicode/language-identifiers.html
  45. LANGUAGE_CODE = 'fr-fr'
  46. SITE_ID = 1
  47. # If you set this to False, Django will make some optimizations so as not
  48. # to load the internationalization machinery.
  49. USE_I18N = True
  50. # If you set this to False, Django will not format dates, numbers and
  51. # calendars according to the current locale.
  52. USE_L10N = True
  53. # If you set this to False, Django will not use timezone-aware datetimes.
  54. USE_TZ = True
  55. # Absolute filesystem path to the directory that will hold user-uploaded files.
  56. # Example: "/var/www/example.com/media/"
  57. MEDIA_ROOT = ''
  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. # Absolute path to the directory static files should be collected to.
  63. # Don't put anything in this directory yourself; store your static files
  64. # in apps' "static/" subdirectories and in STATICFILES_DIRS.
  65. # Example: "/var/www/example.com/static/"
  66. STATIC_ROOT = ''
  67. # URL prefix for static files.
  68. # Example: "http://example.com/static/", "http://static.example.com/"
  69. STATIC_URL = '/static/'
  70. # Additional locations of static files
  71. STATICFILES_DIRS = (
  72. # Put strings here, like "/home/html/static" or "C:/www/django/static".
  73. # Always use forward slashes, even on Windows.
  74. # Don't forget to use absolute paths, not relative paths.
  75. )
  76. # List of finder classes that know how to find static files in
  77. # various locations.
  78. STATICFILES_FINDERS = (
  79. 'django.contrib.staticfiles.finders.FileSystemFinder',
  80. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  81. #'django.contrib.staticfiles.finders.DefaultStorageFinder',
  82. )
  83. # Make this unique, and don't share it with anybody.
  84. SECRET_KEY = '!qy_)gao6q)57#mz1s-d$5^+dp1nt=lk1d19&9bb3co37vn)!3'
  85. # List of callables that know how to import templates from various sources.
  86. TEMPLATE_LOADERS = (
  87. 'django.template.loaders.filesystem.Loader',
  88. 'django.template.loaders.app_directories.Loader',
  89. #'django.template.loaders.eggs.Loader',
  90. )
  91. MIDDLEWARE_CLASSES = (
  92. 'django.middleware.common.CommonMiddleware',
  93. 'django.contrib.sessions.middleware.SessionMiddleware',
  94. 'django.middleware.csrf.CsrfViewMiddleware',
  95. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  96. 'django.contrib.messages.middleware.MessageMiddleware',
  97. # Uncomment the next line for simple clickjacking protection:
  98. # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  99. )
  100. ROOT_URLCONF = 'coin.urls'
  101. # Python dotted path to the WSGI application used by Django's runserver.
  102. WSGI_APPLICATION = 'coin.wsgi.application'
  103. TEMPLATE_DIRS = (
  104. # Only absolute paths, always forward slashes
  105. os.path.join(PROJECT_PATH, 'templates/'),
  106. )
  107. INSTALLED_APPS = (
  108. 'django.contrib.auth',
  109. 'django.contrib.contenttypes',
  110. 'django.contrib.sessions',
  111. #'django.contrib.sites',
  112. 'django.contrib.messages',
  113. 'django.contrib.staticfiles',
  114. # Uncomment the next line to enable the admin:
  115. 'django.contrib.admin',
  116. # Uncomment the next line to enable admin documentation:
  117. #'django.contrib.admindocs',
  118. 'south',
  119. 'ldapdb', # LDAP as database backend
  120. 'autocomplete_light', #Automagic autocomplete foreingkey form component
  121. 'coin.members',
  122. 'coin.offers',
  123. 'coin.billing',
  124. 'coin.resources'
  125. )
  126. # A sample logging configuration. The only tangible logging
  127. # performed by this configuration is to send an email to
  128. # the site admins on every HTTP 500 error when DEBUG=False.
  129. # See http://docs.djangoproject.com/en/dev/topics/logging for
  130. # more details on how to customize your logging configuration.
  131. LOGGING = {
  132. 'version': 1,
  133. 'disable_existing_loggers': False,
  134. 'filters': {
  135. 'require_debug_false': {
  136. '()': 'django.utils.log.RequireDebugFalse'
  137. }
  138. },
  139. 'handlers': {
  140. 'mail_admins': {
  141. 'level': 'ERROR',
  142. 'filters': ['require_debug_false'],
  143. 'class': 'django.utils.log.AdminEmailHandler'
  144. }
  145. },
  146. 'loggers': {
  147. 'django.request': {
  148. 'handlers': ['mail_admins'],
  149. 'level': 'ERROR',
  150. 'propagate': True,
  151. },
  152. }
  153. }
  154. AUTHENTICATION_BACKENDS = (
  155. 'django_auth_ldap.backend.LDAPBackend',
  156. 'django.contrib.auth.backends.ModelBackend',
  157. )
  158. # LDAP Backend pour authentification
  159. AUTH_LDAP_SERVER_URI = "ldap://ldapdev.illyse.org:390"
  160. AUTH_LDAP_START_TLS = True
  161. AUTH_LDAP_GLOBAL_OPTIONS = {ldap.OPT_X_TLS_REQUIRE_CERT: ldap.OPT_X_TLS_NEVER}
  162. AUTH_LDAP_BIND_DN = "cn=illysedev,ou=services,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
  163. AUTH_LDAP_BIND_PASSWORD = "gfj83-E8ECgGh23JK_Ol12"
  164. AUTH_LDAP_USER_SEARCH = LDAPSearch(
  165. "ou=users,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR",
  166. ldap.SCOPE_SUBTREE,
  167. "(cn=%(user)s)"
  168. )
  169. AUTH_LDAP_CACHE_GROUPS = False
  170. AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
  171. "ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR",
  172. ldap.SCOPE_SUBTREE,
  173. "(objectClass=posixGroup)"
  174. )
  175. AUTH_LDAP_GROUP_TYPE = PosixGroupType()
  176. # AUTH_LDAP_REQUIRE_GROUP = "cn=admin,ou=groups,o=ILLYSE,"
  177. # "l=Villeurbanne,st=RHA,c=FR"
  178. AUTH_LDAP_USER_ATTR_MAP = {
  179. "first_name": "givenName",
  180. "last_name": "sn"
  181. }
  182. AUTH_LDAP_USER_FLAGS_BY_GROUP = {
  183. "is_active": "cn=coin,ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR",
  184. "is_staff": "cn=coin_admin,ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR",
  185. "is_superuser": "cn=coin_admin,ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
  186. }
  187. # Surcharge les paramètres en utilisant le fichier settings-local.py
  188. try:
  189. from settings_local import *
  190. except ImportError:
  191. pass