Skip to content

Commit

Permalink
[django] https+hsts zprovozneni na heroku #82
Browse files Browse the repository at this point in the history
na heroku se nepouzivalo production_settings, tedy vsechny moznosti byly aktivni jen na travisu/manualni produkci na lokalu + dodani hsts
  • Loading branch information
rodlukas committed Sep 17, 2019
1 parent f73ef82 commit 473cb9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions scripts/shell/release_tasks_heroku.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env bash
# na heroku neni potreba provadet collectstatic
# na heroku neni potreba provadet collectstatic, export promennych nelze provest

export DJANGO_SETTINGS_MODULE=up.production_settings
python manage.py migrate
18 changes: 10 additions & 8 deletions up/production_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

from .settings import * # lgtm [py/polluting-import]

# pro funkcni testy na Travisu
if os.getenv("TRAVIS"):
MANUAL_PRODUCTION = True
MANUAL_PRODUCTION = True # pro funkcni testy na Travisu
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "frontend", "dist")
] # jen na Travisu (zde se pak slozka smaze)

ALLOWED_HOSTS = [
"uspesnyprvnacek.herokuapp.com",
Expand All @@ -15,18 +17,18 @@

sentry_sdk.init(environment=ENVIRONMENT, integrations=[DjangoIntegration()])

# Static files
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "frontend", "dist")]

# Django konstanty
# Django konstanty pro bezpecnost
SECURE_BROWSER_XSS_FILTER = True
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
SECURE_CONTENT_TYPE_NOSNIFF = True
CSRF_COOKIE_SECURE = True
X_FRAME_OPTIONS = "DENY"

SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 63072000 # 2 roky
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True

if MANUAL_PRODUCTION:
DEBUG = False
ALLOWED_HOSTS.append("localhost")
Expand Down
1 change: 1 addition & 0 deletions up/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
# Static files
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = "/static/"
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

# debug toolbar
DEBUG_TOOLBAR_PANELS = [
Expand Down

0 comments on commit 473cb9e

Please sign in to comment.