|
|
|
"""
|
|
|
|
Django settings for fir_ser project.
|
|
|
|
|
|
|
|
Generated by 'django-admin startproject' using Django 3.0.3.
|
|
|
|
|
|
|
|
For more information on this file, see
|
|
|
|
https://docs.djangoproject.com/en/3.0/topics/settings/
|
|
|
|
|
|
|
|
For the full list of settings and their values, see
|
|
|
|
https://docs.djangoproject.com/en/3.0/ref/settings/
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
|
|
|
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/3.0/howto/deployment/checklist/
|
|
|
|
|
|
|
|
# SECURITY WARNING: keep the secret key used in production secret!
|
|
|
|
SECRET_KEY = 'j!g@^bc(z(a3*i&kp$_@bgb)bug&^#3=amch!3lz&1x&s6ss6t'
|
|
|
|
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
|
|
DEBUG = True
|
|
|
|
|
|
|
|
ALLOWED_HOSTS = ['*']
|
|
|
|
|
|
|
|
# Application definition
|
|
|
|
|
|
|
|
INSTALLED_APPS = [
|
|
|
|
'django.contrib.admin',
|
|
|
|
'django.contrib.auth',
|
|
|
|
'django.contrib.contenttypes',
|
|
|
|
'django.contrib.sessions',
|
|
|
|
'django.contrib.messages',
|
|
|
|
'django.contrib.staticfiles',
|
|
|
|
'api.apps.ApiConfig',
|
|
|
|
'django_apscheduler', # 定时执行任务
|
|
|
|
'rest_framework',
|
|
|
|
'captcha',
|
|
|
|
]
|
|
|
|
|
|
|
|
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',
|
|
|
|
'api.utils.middlewares.CorsMiddleWare'
|
|
|
|
]
|
|
|
|
|
|
|
|
ROOT_URLCONF = 'fir_ser.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',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
WSGI_APPLICATION = 'fir_ser.wsgi.application'
|
|
|
|
|
|
|
|
# Database
|
|
|
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
|
|
|
|
|
|
|
DATABASES = {
|
|
|
|
# 'default': {
|
|
|
|
# 'ENGINE': 'django.db.backends.sqlite3',
|
|
|
|
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
|
|
|
# },
|
|
|
|
'default': {
|
|
|
|
'ENGINE': 'django.db.backends.mysql',
|
|
|
|
'NAME': 'flyapp',
|
|
|
|
'USER': 'flyuser',
|
|
|
|
'PASSWORD': 'KGzKjZpWBp4R4RSa',
|
|
|
|
'HOST': '127.0.0.1',
|
|
|
|
'PORT': '3306',
|
|
|
|
# 设置MySQL的驱动
|
|
|
|
# 'OPTIONS': {'init_command': 'SET storage_engine=INNODB'},
|
|
|
|
'OPTIONS': {'init_command': 'SET sql_mode="STRICT_TRANS_TABLES"', 'charset': 'utf8mb4'}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# Password validation
|
|
|
|
# https://docs.djangoproject.com/en/3.0/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',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
REST_FRAMEWORK = {
|
|
|
|
'DEFAULT_RENDERER_CLASSES': (
|
|
|
|
'rest_framework.renderers.JSONRenderer',
|
|
|
|
)
|
|
|
|
}
|
|
|
|
# Internationalization
|
|
|
|
# https://docs.djangoproject.com/en/3.0/topics/i18n/
|
|
|
|
|
|
|
|
LANGUAGE_CODE = 'en-us'
|
|
|
|
|
|
|
|
TIME_ZONE = 'Asia/Shanghai'
|
|
|
|
|
|
|
|
USE_I18N = True
|
|
|
|
|
|
|
|
USE_L10N = True
|
|
|
|
|
|
|
|
USE_TZ = False
|
|
|
|
|
|
|
|
# Static files (CSS, JavaScript, Images)
|
|
|
|
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
|
|
|
|
|
|
|
STATIC_URL = '/static/'
|
|
|
|
STATICFILES_DIRS = [
|
|
|
|
os.path.join(BASE_DIR, "static")
|
|
|
|
]
|
|
|
|
|
|
|
|
# Media配置
|
|
|
|
MEDIA_URL = "files/"
|
|
|
|
MEDIA_ROOT = os.path.join(BASE_DIR, "files")
|
|
|
|
# supersign配置
|
|
|
|
SUPER_SIGN_ROOT = os.path.join(BASE_DIR, "supersign")
|
|
|
|
|
|
|
|
AUTH_USER_MODEL = "api.UserInfo"
|
|
|
|
|
|
|
|
GEE_TEST = {
|
|
|
|
"gee_test_access_id": "37ca5631edd1e882721808d35163b3ad",
|
|
|
|
"gee_test_access_key": "7eb11ccf3e0953bdd060ed8b60b0c4f5",
|
|
|
|
"verify_status": True, # 是否启用滑动验证码验证组件(True表示启用)
|
|
|
|
"not_verify": [
|
|
|
|
"2ba6b08d53a4fd27057a32537e2d55ae",
|
|
|
|
], # 不用验证的用户(存放着用户的uid)
|
|
|
|
}
|
|
|
|
|
|
|
|
CACHES = {
|
|
|
|
"default": {
|
|
|
|
"BACKEND": "django_redis.cache.RedisCache",
|
|
|
|
"LOCATION": "redis://127.0.0.1:6379",
|
|
|
|
"OPTIONS": {
|
|
|
|
"CLIENT_CLASS": "django_redis.client.DefaultClient",
|
|
|
|
"CONNECTION_POOL_KWARGS": {"max_connections": 100},
|
|
|
|
"PASSWORD": "nineven",
|
|
|
|
"DECODE_RESPONSES": True
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# DRF扩展缓存时间
|
|
|
|
REST_FRAMEWORK_EXTENSIONS = {
|
|
|
|
# 缓存时间
|
|
|
|
'DEFAULT_CACHE_RESPONSE_TIMEOUT': 3600,
|
|
|
|
# 缓存存储
|
|
|
|
'DEFAULT_USE_CACHE': 'default',
|
|
|
|
}
|
|
|
|
|
|
|
|
THIRD_PART_CONFIG = {
|
|
|
|
# 阿里云服务配置
|
|
|
|
"ALI_YUN": {
|
|
|
|
|
|
|
|
},
|
|
|
|
# 滑动验证码服务配置
|
|
|
|
"GEE_TEST": {
|
|
|
|
|
|
|
|
},
|
|
|
|
# APP存储配置
|
|
|
|
'storage': [
|
|
|
|
{
|
|
|
|
'name': 'local',
|
|
|
|
'type': 0,
|
|
|
|
'auth': {
|
|
|
|
'domain_name': 'fly.harmonygames.cn', # 正式环境需要填写正式的访问域名
|
|
|
|
'is_https': True,
|
|
|
|
},
|
|
|
|
'active': True
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name': 'aliyun',
|
|
|
|
'type': 2,
|
|
|
|
'auth': {
|
|
|
|
'access_key': 'LTAI4FkbTR',
|
|
|
|
'secret_key': '2iLIxy9',
|
|
|
|
'bucket_name': 'fge',
|
|
|
|
'sts_role_arn': 'ap-sage',
|
|
|
|
'endpoint': 'oss-cn-beijing.aliyuncs.com',
|
|
|
|
'is_https': True,
|
|
|
|
'domain_name': 'aoud.xin'
|
|
|
|
},
|
|
|
|
'active': False
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'name': 'qiniuyun',
|
|
|
|
'type': 1,
|
|
|
|
'auth': {
|
|
|
|
'access_key': 'mT4fiJ',
|
|
|
|
'secret_key': '0G9fXfhYLynv',
|
|
|
|
'bucket_name': 'fge',
|
|
|
|
'is_https': False,
|
|
|
|
'domain_name': 'foud.xin'
|
|
|
|
},
|
|
|
|
'active': False
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
CACHE_KEY_TEMPLATE = {
|
|
|
|
'download_times_key': 'app_download_times',
|
|
|
|
'make_token_key': 'make_token',
|
|
|
|
'download_short_key': 'download_short',
|
|
|
|
'app_instance_key': 'app_instance',
|
|
|
|
'download_url_key': 'download_url',
|
|
|
|
'user_storage_key': 'storage_auth',
|
|
|
|
'user_auth_token_key': 'user_auth_token',
|
|
|
|
'download_today_times_key': 'download_today_times',
|
|
|
|
'developer_auth_code_key': 'developer_auth_code',
|
|
|
|
'upload_file_tmp_name_key': 'upload_file_tmp_name',
|
|
|
|
'login_failed_try_times_key': 'login_failed_try_times',
|
|
|
|
}
|
|
|
|
|
|
|
|
DATA_DOWNLOAD_KEY = "d_token"
|
|
|
|
DATA_DOWNLOAD_KEY_OPEN = True # 是否开启图片和应用下载token,只本地存储支持该操作
|
|
|
|
FILE_UPLOAD_TMP_KEY = ".tmp"
|
|
|
|
|
|
|
|
SYNC_CACHE_TO_DATABASE = {
|
|
|
|
'download_times': 10, # 下载次数同步时间
|
|
|
|
'auto_clean_tmp_file_times': 60 * 30, # 定时清理上传失误生成的临时文件
|
|
|
|
'auto_clean_apscheduler_log': 100000, # 定时清理定时任务执行的日志,该参数为日志保留的数量
|
|
|
|
'try_login_times': 5, # 当天登录失败次数,超过该失败次数,锁定24小时
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_DOMAIN = {
|
|
|
|
'IOS_PMFILE_DOWNLOAD_DOMAIN': {
|
|
|
|
"domain_name": 'fly.harmonygames.cn',
|
|
|
|
'is_https': True,
|
|
|
|
}, # ios 描述文件和plist文件下载域名,该域名用于后端,一般为api访问域名
|
|
|
|
'POST_UDID_DOMAIN': 'https://fly.harmonygames.cn', # 超级签名 安装签名时 向该域名 发送udid数据,该域名用于后端,一般为 api 访问域名
|
|
|
|
'REDIRECT_UDID_DOMAIN': 'https://fly.harmonygames.cn', # 超级签名 安装完成之后,跳转域名,该域名为前端web访问域名
|
|
|
|
}
|
|
|
|
|
|
|
|
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
|
|
|
SESSION_CACHE_ALIAS = "default"
|
|
|
|
|
|
|
|
CAPTCHA_TIMEOUT=5 # Minutes
|
|
|
|
CAPTCHA_LENGTH= 6 # Chars
|
|
|
|
|
|
|
|
|
|
|
|
BASE_LOG_DIR = os.path.join(BASE_DIR, "logs")
|
|
|
|
LOGGING = {
|
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers': False,
|
|
|
|
'formatters': {
|
|
|
|
'standard': {
|
|
|
|
'format': '[%(asctime)s][%(threadName)s:%(thread)d][task_id:%(name)s][%(filename)s:%(lineno)d]'
|
|
|
|
'[%(levelname)s][%(message)s]'
|
|
|
|
},
|
|
|
|
'simple': {
|
|
|
|
'format': '[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d]%(message)s'
|
|
|
|
},
|
|
|
|
'collect': {
|
|
|
|
'format': '%(message)s'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'filters': {
|
|
|
|
'require_debug_true': {
|
|
|
|
'()': 'django.utils.log.RequireDebugTrue',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers': {
|
|
|
|
'console': {
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'filters': ['require_debug_true'], # 只有在Django debug为True时才在屏幕打印日志
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'simple'
|
|
|
|
},
|
|
|
|
'TF': {
|
|
|
|
'level': 'INFO',
|
|
|
|
'class': 'logging.handlers.TimedRotatingFileHandler', # 保存到文件,根据时间自动切
|
|
|
|
'filename': os.path.join(BASE_LOG_DIR, "flyapp_info.log"), # 日志文件
|
|
|
|
'backupCount': 10, # 备份数为3 xx.log --> xx.log.2018-08-23_00-00-00 --> xx.log.2018-08-24_00-00-00 --> ...
|
|
|
|
'when': 'D', # 每天一切, 可选值有S/秒 M/分 H/小时 D/天 W0-W6/周(0=周一) midnight/如果没指定时间就默认在午夜
|
|
|
|
'formatter': 'standard',
|
|
|
|
'encoding': 'utf-8',
|
|
|
|
},
|
|
|
|
'error': {
|
|
|
|
'level': 'ERROR',
|
|
|
|
'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切
|
|
|
|
'filename': os.path.join(BASE_LOG_DIR, "flyapp_err.log"), # 日志文件
|
|
|
|
'maxBytes': 1024 * 1024 * 5, # 日志大小 50M
|
|
|
|
'backupCount': 10,
|
|
|
|
'formatter': 'standard',
|
|
|
|
'encoding': 'utf-8',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'': { # 默认的logger应用如下配置
|
|
|
|
'handlers': ['TF', 'console', 'error'], # 上线之后可以把'console'移除
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'propagate': True,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|