settings.py 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. """
  2. Django settings for glitchtip project.
  3. Generated by 'django-admin startproject' using Django 3.0rc1.
  4. For more information on this file, see
  5. https://docs.djangoproject.com/en/dev/topics/settings/
  6. For the full list of settings and their values, see
  7. https://docs.djangoproject.com/en/dev/ref/settings/
  8. """
  9. import os
  10. import environ
  11. import sentry_sdk
  12. from sentry_sdk.integrations.django import DjangoIntegration
  13. env = environ.Env(
  14. DEBUG=(bool, True),
  15. DEBUG_TOOLBAR=(bool, False),
  16. AWS_ACCESS_KEY_ID=(str, None),
  17. AWS_SECRET_ACCESS_KEY=(str, None),
  18. AWS_STORAGE_BUCKET_NAME=(str, None),
  19. AWS_S3_ENDPOINT_URL=(str, None),
  20. AWS_LOCATION=(str, None),
  21. STATIC_URL=(str, "/static/"),
  22. STATICFILES_STORAGE=(
  23. str,
  24. "whitenoise.storage.CompressedManifestStaticFilesStorage",
  25. ),
  26. )
  27. path = environ.Path()
  28. # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  29. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  30. # Quick-start development settings - unsuitable for production
  31. # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/
  32. # SECURITY WARNING: keep the secret key used in production secret!
  33. SECRET_KEY = env("SECRET_KEY")
  34. # SECURITY WARNING: don't run with debug turned on in production!
  35. DEBUG = env("DEBUG")
  36. ALLOWED_HOSTS = ["*"]
  37. GLITCHTIP_ENDPOINT = env.url("GLITCHTIP_ENDPOINT", default="http://localhost:8000")
  38. # For development purposes only, prints out inbound event store json
  39. EVENT_STORE_DEBUG = env.bool("EVENT_STORE_DEBUG", False)
  40. # GlitchTip can track GlichTip's own errors.
  41. # If enabling this, use a different server to avoid infinite loops.
  42. sentry_sdk.init(
  43. dsn=env.str("SENTRY_DSN", None), integrations=[DjangoIntegration()],
  44. )
  45. def show_toolbar(request):
  46. return env("DEBUG_TOOLBAR")
  47. DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}
  48. # Application definition
  49. INSTALLED_APPS = [
  50. "django.contrib.auth",
  51. "django.contrib.contenttypes",
  52. "django.contrib.sessions",
  53. "django.contrib.messages",
  54. "django.contrib.staticfiles",
  55. "django.contrib.sites",
  56. "allauth",
  57. "allauth.account",
  58. "corsheaders",
  59. "django_filters",
  60. "debug_toolbar",
  61. "rest_framework",
  62. "rest_framework.authtoken",
  63. "rest_auth",
  64. "storages",
  65. "organizations",
  66. "event_store",
  67. "issues",
  68. "users",
  69. "projects",
  70. ]
  71. MIDDLEWARE = [
  72. "django.middleware.security.SecurityMiddleware",
  73. "django.contrib.sessions.middleware.SessionMiddleware",
  74. "corsheaders.middleware.CorsMiddleware",
  75. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  76. "whitenoise.middleware.WhiteNoiseMiddleware",
  77. "debug_toolbar.middleware.DebugToolbarMiddleware",
  78. "django.middleware.common.CommonMiddleware",
  79. "django.middleware.csrf.CsrfViewMiddleware",
  80. "django.contrib.auth.middleware.AuthenticationMiddleware",
  81. "django.contrib.messages.middleware.MessageMiddleware",
  82. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  83. "glitchtip.middleware.proxy.DecompressBodyMiddleware",
  84. ]
  85. ROOT_URLCONF = "glitchtip.urls"
  86. TEMPLATES = [
  87. {
  88. "BACKEND": "django.template.backends.django.DjangoTemplates",
  89. "DIRS": [path("dist"), path("templates")],
  90. "APP_DIRS": True,
  91. "OPTIONS": {
  92. "context_processors": [
  93. "django.template.context_processors.debug",
  94. "django.template.context_processors.request",
  95. "django.contrib.auth.context_processors.auth",
  96. "django.contrib.messages.context_processors.messages",
  97. ],
  98. },
  99. },
  100. ]
  101. WSGI_APPLICATION = "glitchtip.wsgi.application"
  102. CORS_ORIGIN_ALLOW_ALL = env.bool("CORS_ORIGIN_ALLOW_ALL", True)
  103. CORS_ORIGIN_WHITELIST = env.tuple("CORS_ORIGIN_WHITELIST", str, default=())
  104. X_FRAME_OPTIONS = "DENY"
  105. SECURE_BROWSER_XSS_FILTER = True
  106. SECURE_CONTENT_TYPE_NOSNIFF = True
  107. ENVIRONMENT = env.str("ENVIRONMENT", None)
  108. GLITCHTIP_VERSION = env.str("GLITCHTIP_VERSION", "dev")
  109. # Database
  110. # https://docs.djangoproject.com/en/dev/ref/settings/#databases
  111. DATABASES = {"default": env.db(default="postgres://postgres:postgres@db:5432/postgres")}
  112. # Password validation
  113. # https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
  114. AUTH_PASSWORD_VALIDATORS = [
  115. {
  116. "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  117. },
  118. {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
  119. {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
  120. {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
  121. ]
  122. # Internationalization
  123. # https://docs.djangoproject.com/en/dev/topics/i18n/
  124. LANGUAGE_CODE = "en-us"
  125. TIME_ZONE = "UTC"
  126. USE_I18N = True
  127. USE_L10N = True
  128. USE_TZ = True
  129. SITE_ID = 1
  130. # Static files (CSS, JavaScript, Images)
  131. # https://docs.djangoproject.com/en/dev/howto/static-files/
  132. STATIC_URL = env("STATIC_URL")
  133. AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID")
  134. AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY")
  135. AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME")
  136. AWS_S3_ENDPOINT_URL = env("AWS_S3_ENDPOINT_URL")
  137. AWS_LOCATION = env("AWS_LOCATION")
  138. STATICFILES_DIRS = [
  139. "dist",
  140. ]
  141. STATIC_ROOT = path("static/")
  142. STATICFILES_STORAGE = env("STATICFILES_STORAGE")
  143. EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
  144. AUTH_USER_MODEL = "users.User"
  145. ACCOUNT_AUTHENTICATION_METHOD = "email"
  146. ACCOUNT_EMAIL_REQUIRED = True
  147. ACCOUNT_USERNAME_REQUIRED = False
  148. AUTHENTICATION_BACKENDS = (
  149. # Needed to login by username in Django admin, regardless of `allauth`
  150. "django.contrib.auth.backends.ModelBackend",
  151. # `allauth` specific authentication methods, such as login by e-mail
  152. "allauth.account.auth_backends.AuthenticationBackend",
  153. )
  154. REST_FRAMEWORK = {
  155. "DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated",],
  156. "DEFAULT_PAGINATION_CLASS": "glitchtip.pagination.LinkHeaderPagination",
  157. "PAGE_SIZE": 50,
  158. "DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",),
  159. }