forked from lazzyfu/goInsight
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings-bak.py
More file actions
262 lines (216 loc) · 7.34 KB
/
settings-bak.py
File metadata and controls
262 lines (216 loc) · 7.34 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
"""
Django settings for sqlaudit project.
Generated by 'django-admin startproject' using Django 2.1.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import sys
import ldap
from django_auth_ldap.config import LDAPSearch
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '4bu!%e83a94zn-8)s4sk*a4fd4l!t9^opi21+a1&j(0m5-8eg2'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Define apps path
sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
# define user auth model
AUTH_USER_MODEL = 'users.UserAccounts'
# Define login page
LOGIN_URL = '/users/login/'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'channels',
'django_celery_results',
'django_celery_beat',
'users',
'sqlquery',
'sqlorders',
'webshell'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'sqlaudit.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'context_processors.global_values.get_order_enviroment',
'context_processors.global_values.get_mail_status',
],
},
},
]
WSGI_APPLICATION = 'sqlaudit.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sqlaudit',
'USER': 'root',
'HOST': 'localhost',
'PASSWORD': 'fuzongfei168',
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
'charset': 'utf8mb4'
}
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '/static/')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# 使用redis缓存session
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
}
}
# celery for redis
# 由于celery-4.1.0存在时区bug,必须使用UTC时区
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379'
CELERY_BROKER_URL = 'redis://127.0.0.1:6379'
CELERY_TIMEZONE = 'UTC'
CELERY_ENABLE_UTC = True
CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler'
# django-channels配置
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("127.0.0.1", 6379)],
},
},
}
ASGI_APPLICATION = "sqlaudit.routing.application"
# Inception配置
INCEPTION_HOST = '127.0.0.1'
INCEPTION_PORT = 6033
# 邮箱设置
EMAIL_HOST = 'smtp.exmail.qq.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'xxx@qq.com'
EMAIL_HOST_PASSWORD = 'xxx@2017'
EMAIL_FROM = "xxx@qq.com"
EMAIL_USE_SSL = True
# Enable ldap backend support
AUTHENTICATION_BACKENDS = [
# 'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
]
# LDAP配置
# 根据公司的ldap进行配置
AUTH_LDAP_SERVER_URI = "ldap://ldap.tt.com:389"
AUTH_LDAP_ALWAYS_UPDATE_USER = True
# uid为用户名,password为该用户的密码
AUTH_LDAP_BIND_DN = "uid=devops,cn=users,cn=accounts,dc=test,dc=com"
AUTH_LDAP_BIND_PASSWORD = "123.com"
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=people,dc=tt,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
# 下面字段必须存在,管理字段可自定义
# key:value key:django字段,value:LDAP字段
# username:用户名,email:邮箱地址,displayname:中文名或昵称
# 按照自己公司的LDAP配置字段进行修改映射
AUTH_LDAP_USER_ATTR_MAP = {"username": "username", 'email': 'mail', "displayname": 'givenName', 'mobile': 'mobile'}
# 日志
# LOGGING = {
# 'version': 1,
# 'disable_existing_loggers': True,
# 'formatters': { # 日志格式
# 'standard': {
# 'format': '%(asctime)s [%(threadName)s:%(thread)d] [%(name)s:%(lineno)d] '
# '[%(module)s:%(funcName)s] [%(levelname)s]- %(message)s'}
# },
# 'handlers': { # 处理器
# 'file': { # 记录到日志文件(需要创建对应的目录,否则会出错)
# 'level': 'DEBUG',
# 'class': 'logging.handlers.RotatingFileHandler',
# 'filename': 'logs/all.log', # 日志输出文件
# 'maxBytes': 1024 * 1024 * 5, # 文件大小
# 'backupCount': 5, # 备份份数
# 'formatter': 'standard', # 使用哪种formatters日志格式
# },
# 'console': { # 输出到控制台
# 'level': 'DEBUG',
# 'class': 'logging.StreamHandler',
# 'formatter': 'standard',
# },
# },
# 'loggers': { # logging管理器
# 'django': {
# 'handlers': ['file', 'console'],
# 'level': 'INFO',
# 'propagate': False
# },
# 'django.request': {
# 'handlers': ['file'],
# 'level': 'INFO',
# 'propagate': True,
# },
# 'django_auth_ldap': {
# 'level': 'DEBUG',
# 'handlers': ['file', 'console'],
# },
# }
# }