Enable HSTS seconds
This commit is contained in:
parent
34fd41cff6
commit
b1921940f0
@ -17,6 +17,8 @@ The following environment variables have to be set:
|
||||
- DJANGO_MEDIA_ROOT
|
||||
- DJANGO_POSTGRESQL_SOCKET
|
||||
|
||||
The following can be set
|
||||
- DJANGO_SECURE_HSTS_SECONDS (defaults to 120)
|
||||
|
||||
"""
|
||||
|
||||
@ -26,10 +28,12 @@ import os
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
def get_env_value(env_variable):
|
||||
def get_env_value(env_variable, default=None):
|
||||
try:
|
||||
return os.environ[env_variable]
|
||||
except KeyError:
|
||||
if default is not None:
|
||||
return default
|
||||
error_msg = 'Set the {} environment variable'.format(env_variable)
|
||||
raise Exception(error_msg)
|
||||
|
||||
@ -226,3 +230,5 @@ SESSION_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
|
||||
SECURE_SSL_REDIRECT = True
|
||||
|
||||
SECURE_HSTS_SECONDS = get_env_value('DJANGO_SECURE_HSTS_SECONDS', default=120)
|
Loading…
Reference in New Issue
Block a user