settings.py 7.0 KB

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