This repository was archived by the owner on Mar 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_settings.py
More file actions
91 lines (81 loc) · 3.33 KB
/
example_settings.py
File metadata and controls
91 lines (81 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Django settings for sal project.
from system_settings import *
from settings_import import *
DATABASES = {
'default': {
# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'ENGINE': 'django.db.backends.sqlite3',
# Or path to database file if using sqlite3.
'NAME': os.path.join(PROJECT_DIR, 'db/sal.db'),
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Memcached
if 'MEMCACHED_PORT_11211_TCP_ADDR' in os.environ:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': [
'%s:%s' % (os.environ['MEMCACHED_PORT_11211_TCP_ADDR'],
os.environ['MEMCACHED_PORT_11211_TCP_PORT']),
]
}
}
# PG Database
host = None
port = None
if 'DB_USER' in os.environ:
if 'DB_HOST' in os.environ:
host = os.environ.get('DB_HOST')
port = os.environ.get('DB_PORT', '5432')
elif 'DB_PORT_5432_TCP_ADDR' in os.environ:
host = os.environ.get('DB_PORT_5432_TCP_ADDR')
port = os.environ.get('DB_PORT_5432_TCP_PORT', '5432')
else:
host = 'db'
port = '5432'
if host and port:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASS'],
'HOST': host,
'PORT': port,
}
}
# ActiveDirectory Connection
AUTHENTICATION_BACKENDS = [
'server.ADConnector.ADConnector',
'django.contrib.auth.backends.ModelBackend',
]
AUTH_LDAP_SERVER_URI = 'ldaps://hostname.company.com:636'
AUTH_LDAP_USER_DOMAIN = 'company.com'
AUTH_LDAP_USER_SEARCH = ('DC=ch,DC=ads,DC=company,DC=com',
'DC=uk,DC=ads,DC=company,DC=com',
'DC=us,DC=ads,DC=company,DC=com')
AUTH_LDAP_USER_ATTR_MAP = {
"username": "sAMAccountName",
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
AUTH_LDAP_USER_PREFIX = 'ldap_' # Prefix of django username compared to ldap username
# LDAP SAL Mapping
AUTH_LDAP_USER_PROFILE = {
'RO': ('CN=users-all,DC=department,DC=ad,DC=company,DC=com',),
'RW': ('CN=service-desk,DC=department,DC=ad,DC=company,DC=com',
'CN=group-leader,OU=group,DC=department,DC=ad,DC=company,DC=com'),
'GA': 'CN=admin,DC=department,DC=ad,DC=company,DC=com',
}
AUTH_LDAP_USER_TO_BUSINESS_UNIT = {
'#ALL_BU': ('CN=service-desk,OU=it,DC=ad,DC=company,DC=com',
'CN=sysadmins,OU=it,DC=ad,DC=company,DC=com',),
'CH': ('CN=mac-admins,OU=it,DC=ch,DC=ad,DC=company,DC=com',),
'UK': ('CN=mac-admins,OU=it,DC=uk,DC=ad,DC=company,DC=com',),
'US': 'CN=mac-admins,OU=it,DC=us,DC=ad,DC=company,DC=com',
}