settings.py 7.1 KB

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