settings.py 7.3 KB

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