""" Django settings for mobeesia project. Generated by 'django-admin startproject' using Django 3.0.2. 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 from django.conf.locale.pt_BR import formats as pt_br_formats from corsheaders.defaults import default_headers from datetime import timedelta pt_br_formats.DATETIME_FORMAT = "Y-M-d H:i:s" # 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 = '=d1iqb7*a1im61xd_47s7t9n(!m#c(q_8ls*t1)z&k%n66#gm2' ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'import_export', 'wap.apps.WapConfig', 'adm.apps.AdmConfig', 'dashboard.apps.DashboardConfig', 'signer.apps.SignerConfig', 'go.apps.GoConfig', 'corsheaders', 'cloud_browser', 'django_prometheus', ] MIDDLEWARE = [ 'django_prometheus.middleware.PrometheusBeforeMiddleware', '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', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.BrokenLinkEmailsMiddleware', 'django.middleware.common.CommonMiddleware', 'django_prometheus.middleware.PrometheusAfterMiddleware', ] CORS_ORIGIN_ALLOW_ALL = True CORS_ALLOW_HEADERS = list(default_headers) + ['X-Username'] CORS_ORIGIN_WHITELIST = ( 'https://mobees.com.br', 'https://www.mobees.com.br', 'https://mobees.webflow.io', 'https://parceiros.mobees.com.br', 'https://admin.mobees.com.br', 'https://go.mobees.com.br', 'https://parceiros.stg.mobees.com.br', 'https://admin.stg.mobees.com.br', 'https://go.stg.mobees.com.br', 'http://localhost', 'http://localhost:8000', 'http://localhost:8080', 'http://localhost:9090', 'http://localhost:7070', 'http://127.0.0.1:8887', 'https://management.azure.com', 'https://login.microsoftonline.com' ) ROOT_URLCONF = 'mobeesia.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': ['./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 = 'mobeesia.wsgi.application' # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases SQLALCHEMY_QUEUEPOOL = { 'pool_size': 80, 'max_overflow': 50, 'timeout': 5 } DEFAULT_FILE_STORAGE = 'adm.storage.MediaStorage' #CLOUD_BROWSER SOMENTE AWS CLOUD_BROWSER_VIEW_DECORATOR = "django.contrib.admin.views.decorators.staff_member_required" CLOUD_BROWSER_DATASTORE = "AWS" # 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', }, ] AUTHENTICATION_BACKENDS = [ 'adm.authentication.MobeesBackend', ] IMPORT_EXPORT_USE_TRANSACTIONS = True # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ LANGUAGE_CODE = 'pt-br' TIME_ZONE = 'America/Sao_Paulo' USE_I18N = True USE_L10N = True USE_TZ = False REST_FRAMEWORK = { 'TIME_INPUT_FORMATS': ('%H:%M:%S', ) } # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, "static/") # Additional locations of static files STATICFILES_DIRS = ( # location of your application, should not be public web accessible os.path.join(BASE_DIR, "adm/static/"), ) # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'file': { 'level': 'INFO', 'class':'logging.handlers.RotatingFileHandler', 'filename': os.path.join(BASE_DIR, 'mobeesia.log'), 'maxBytes': 1024*1024*15, 'backupCount': 10, 'formatter': 'verbose', }, 'slack': { 'level': 'INFO', 'class': 'mobeesia.msgservice.MsgServiceHandler', 'formatter': 'verbose', }, 'slack_operacao': { 'level': 'INFO', 'class': 'mobeesia.msgservice.MsgOperacaoHandler', 'formatter': 'verbose', }, 'console': { 'level': 'INFO', 'filters': ['require_debug_true'], 'class': 'logging.StreamHandler', 'formatter': 'simple' }, }, 'filters': { 'require_debug_true': { '()': 'django.utils.log.RequireDebugTrue', }, }, 'formatters': { 'verbose': { 'format': '%(levelname)s | %(asctime)s | %(message)s', 'datefmt' : "%Y-%m-%d %H:%M:%S" }, 'simple': { 'format': '{levelname} {message}', 'style': '{', }, }, 'loggers': { 'mobeesia': { 'handlers': ['file','slack'], 'level': 'INFO', 'propagate': True, }, 'operacao': { 'handlers': ['file','slack_operacao'], 'level': 'INFO', 'propagate': True, }, 'django': { 'handlers': ['console'], 'propagate': True, }, 'django.request': { 'handlers': ['file','slack','console'], 'level': 'ERROR', 'propagate': False, }, }, } SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(days=365), # minutes=30 'REFRESH_TOKEN_LIFETIME': timedelta(days=365), 'ROTATE_REFRESH_TOKENS': False, 'BLACKLIST_AFTER_ROTATION': True, 'UPDATE_LAST_LOGIN': False, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUDIENCE': None, 'ISSUER': None, 'AUTH_HEADER_TYPES': ('Bearer',), 'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION', 'USER_ID_FIELD': 'id_usuario', 'USER_ID_CLAIM': 'id_usuario', 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', 'JTI_CLAIM': 'jti', 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp', 'SLIDING_TOKEN_LIFETIME': timedelta(minutes=5), 'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1), } EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp-relay.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_USE_SSL = False EMAIL_HOST_USER = 'suporte@mobees.com.br' EMAIL_HOST_PASSWORD = 'GoMobees2019!' EMAIL_HOST_CONTACT_USER = 'contato@mobees.com.br' EMAIL_HOST_CONTACT_PASSWORD = 'GoMobees2019!' SESSION_SAVE_EVERY_REQUEST = True