1
0

settings.py 6.8 KB

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