settings.py 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. sentry_sdk.init(
  39. dsn="http://9c31decfd46843ffb3c0ea548b71aafc@192.168.86.139:8000/1",
  40. integrations=[DjangoIntegration()],
  41. )
  42. def show_toolbar(request):
  43. return env("DEBUG_TOOLBAR")
  44. DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": show_toolbar}
  45. # Application definition
  46. INSTALLED_APPS = [
  47. "django.contrib.auth",
  48. "django.contrib.contenttypes",
  49. "django.contrib.sessions",
  50. "django.contrib.messages",
  51. "django.contrib.staticfiles",
  52. "django.contrib.sites",
  53. "allauth",
  54. "allauth.account",
  55. "corsheaders",
  56. "debug_toolbar",
  57. "rest_framework",
  58. "rest_framework.authtoken",
  59. "rest_auth",
  60. "storages",
  61. "organizations",
  62. "issues",
  63. "users",
  64. "projects",
  65. ]
  66. MIDDLEWARE = [
  67. "django.middleware.security.SecurityMiddleware",
  68. "django.contrib.sessions.middleware.SessionMiddleware",
  69. "corsheaders.middleware.CorsMiddleware",
  70. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  71. "whitenoise.middleware.WhiteNoiseMiddleware",
  72. "debug_toolbar.middleware.DebugToolbarMiddleware",
  73. "django.middleware.common.CommonMiddleware",
  74. "django.middleware.csrf.CsrfViewMiddleware",
  75. "django.contrib.auth.middleware.AuthenticationMiddleware",
  76. "django.contrib.messages.middleware.MessageMiddleware",
  77. "django.middleware.clickjacking.XFrameOptionsMiddleware",
  78. "glitchtip.middleware.proxy.DecompressBodyMiddleware",
  79. ]
  80. ROOT_URLCONF = "glitchtip.urls"
  81. TEMPLATES = [
  82. {
  83. "BACKEND": "django.template.backends.django.DjangoTemplates",
  84. "DIRS": [path("dist")],
  85. "APP_DIRS": True,
  86. "OPTIONS": {
  87. "context_processors": [
  88. "django.template.context_processors.debug",
  89. "django.template.context_processors.request",
  90. "django.contrib.auth.context_processors.auth",
  91. "django.contrib.messages.context_processors.messages",
  92. ],
  93. },
  94. },
  95. ]
  96. WSGI_APPLICATION = "glitchtip.wsgi.application"
  97. CORS_ORIGIN_ALLOW_ALL = env.bool("CORS_ORIGIN_ALLOW_ALL", True)
  98. CORS_ORIGIN_WHITELIST = env.tuple("CORS_ORIGIN_WHITELIST", str, default=())
  99. X_FRAME_OPTIONS = "DENY"
  100. SECURE_BROWSER_XSS_FILTER = True
  101. SECURE_CONTENT_TYPE_NOSNIFF = True
  102. ENVIRONMENT = env.str("ENVIRONMENT", None)
  103. GLITCH_VERSION = env.str("PASSIT_VERSION", "dev")
  104. # Database
  105. # https://docs.djangoproject.com/en/dev/ref/settings/#databases
  106. DATABASES = {"default": env.db(default="postgres://postgres:postgres@db:5432/postgres")}
  107. # Password validation
  108. # https://docs.djangoproject.com/en/dev/ref/settings/#auth-password-validators
  109. AUTH_PASSWORD_VALIDATORS = [
  110. {
  111. "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
  112. },
  113. {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
  114. {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
  115. {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
  116. ]
  117. # Internationalization
  118. # https://docs.djangoproject.com/en/dev/topics/i18n/
  119. LANGUAGE_CODE = "en-us"
  120. TIME_ZONE = "UTC"
  121. USE_I18N = True
  122. USE_L10N = True
  123. USE_TZ = True
  124. SITE_ID = 1
  125. # Static files (CSS, JavaScript, Images)
  126. # https://docs.djangoproject.com/en/dev/howto/static-files/
  127. STATIC_URL = env("STATIC_URL")
  128. AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID")
  129. AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY")
  130. AWS_STORAGE_BUCKET_NAME = env("AWS_STORAGE_BUCKET_NAME")
  131. AWS_S3_ENDPOINT_URL = env("AWS_S3_ENDPOINT_URL")
  132. AWS_LOCATION = env("AWS_LOCATION")
  133. STATICFILES_DIRS = [
  134. "dist",
  135. ]
  136. STATIC_ROOT = path("static/")
  137. STATICFILES_STORAGE = env("STATICFILES_STORAGE")
  138. EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
  139. AUTH_USER_MODEL = "users.User"
  140. ACCOUNT_AUTHENTICATION_METHOD = "email"
  141. ACCOUNT_EMAIL_REQUIRED = True
  142. ACCOUNT_USERNAME_REQUIRED = False
  143. AUTHENTICATION_BACKENDS = (
  144. # Needed to login by username in Django admin, regardless of `allauth`
  145. "django.contrib.auth.backends.ModelBackend",
  146. # `allauth` specific authentication methods, such as login by e-mail
  147. "allauth.account.auth_backends.AuthenticationBackend",
  148. )
  149. REST_FRAMEWORK = {
  150. "DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated",],
  151. "DEFAULT_PAGINATION_CLASS": "glitchtip.pagination.LinkHeaderPagination",
  152. "PAGE_SIZE": 50,
  153. }