""" Django settings for glitchtip project. Generated by 'django-admin startproject' using Django 3.0rc1. For more information on this file, see https://docs.djangoproject.com/en/dev/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/dev/ref/settings/ """ import os import environ import sentry_sdk from sentry_sdk.integrations.django import DjangoIntegration env = environ.Env( DEBUG=(bool, True), DEBUG_TOOLBAR=(bool, False), AWS_ACCESS_KEY_ID=(str, None), AWS_SECRET_ACCESS_KEY=(str, None), AWS_STORAGE_BUCKET_NAME=(str, None), AWS_S3_ENDPOINT_URL=(str, None), AWS_LOCATION=(str, None), STATIC_URL=(str, "/static/"), STATICFILES_STORAGE=( str, "whitenoise.storage.CompressedManifestStaticFilesStorage", ), ) path = environ.Path() # 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/dev/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = env("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env("DEBUG") ALLOWED_HOSTS = ["*"] GLITCHTIP_ENDPOINT = env.url("GLITCHTIP_ENDPOINT", default="http://localhost:8000") # For development purposes only, prints out inbound event store json EVENT_STORE_DEBUG = env.bool("EVENT_STORE_DEBUG", False) # GlitchTip can track GlichTip's own errors. # If enabling this, use a different server to avoid infinite loops. sentry_sdk.init( dsn=env.str("SENTRY_DSN", None), integrations=[DjangoIntegration()], ) def show_toolbar(request): return env("DEBUG_TOOLBAR") DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar} # Application definition INSTALLED_APPS = [ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "django.contrib.sites", "allauth", "allauth.account", "corsheaders", "django_filters", "debug_toolbar", "rest_framework", "rest_framework.authtoken", "rest_auth", "storages", "organizations", "event_store", "issues", "users", "projects", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "corsheaders.middleware.CorsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware", "debug_toolbar.middleware.DebugToolbarMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "glitchtip.middleware.proxy.DecompressBodyMiddleware", ] ROOT_URLCONF = "glitchtip.urls" TEMPLATES = [ { "BACKEND": "django.template.backends.django.DjangoTemplates", "DIRS": [path("dist"), path("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 = "glitchtip.wsgi.application" CORS_ORIGIN_ALLOW_ALL = env.bool("CORS_ORIGIN_ALLOW_ALL", True) CORS_ORIGIN_WHITELIST = env.tuple("CORS_ORIGIN_WHITELIST", str, default=()) X_FRAME_OPTIONS = "DENY" SECURE_BROWSER_XSS_FILTER = True SECURE_CONTENT_TYPE_NOSNIFF = True ENVIRONMENT = env.str("ENVIRONMENT", None) GLITCHTIP_VERSION = env.str("GLITCHTIP_VERSION", "dev") # Database # https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = {"default": env.db(default="postgres://postgres:postgres@db:5432/postgres")} # Password validation # https://docs.djangoproject.com/en/dev/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/dev/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "UTC" USE_I18N = True USE_L10N = True USE_TZ = True SITE_ID = 1 # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/dev/howto/static-files/ STATIC_URL = env("STATIC_URL") AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID") AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY") AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME") AWS_S3_ENDPOINT_URL = env("AWS_S3_ENDPOINT_URL") AWS_LOCATION = env("AWS_LOCATION") STATICFILES_DIRS = [ "dist", ] STATIC_ROOT = path("static/") STATICFILES_STORAGE = env("STATICFILES_STORAGE") EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" AUTH_USER_MODEL = "users.User" ACCOUNT_AUTHENTICATION_METHOD = "email" ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_USERNAME_REQUIRED = False AUTHENTICATION_BACKENDS = ( # Needed to login by username in Django admin, regardless of `allauth` "django.contrib.auth.backends.ModelBackend", # `allauth` specific authentication methods, such as login by e-mail "allauth.account.auth_backends.AuthenticationBackend", ) REST_FRAMEWORK = { "DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated",], "DEFAULT_PAGINATION_CLASS": "glitchtip.pagination.LinkHeaderPagination", "PAGE_SIZE": 50, "DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",), }