From b921ab7f021a0c2ad65fa473e2d2dfe6e3fd8a8a Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 23 Oct 2019 08:15:08 +0000 Subject: [PATCH] disable browsable API in production --- .../djangormm/local_settings.py.example | 18 ++++++++++++++++++ api/djangormm/djangormm/settings.py | 10 ---------- install.sh | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/api/djangormm/djangormm/local_settings.py.example b/api/djangormm/djangormm/local_settings.py.example index a202fd3e..88268c65 100644 --- a/api/djangormm/djangormm/local_settings.py.example +++ b/api/djangormm/djangormm/local_settings.py.example @@ -17,6 +17,24 @@ DATABASES = { } } +REST_FRAMEWORK = { + 'DATETIME_FORMAT': "%b-%d-%Y - %H:%M", + + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', + ), + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'knox.auth.TokenAuthentication', + ), +} + +if not DEBUG: + REST_FRAMEWORK.update({ + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) + }) + EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'example@gmail.com' diff --git a/api/djangormm/djangormm/settings.py b/api/djangormm/djangormm/settings.py index ec3145ca..4bfa0c57 100644 --- a/api/djangormm/djangormm/settings.py +++ b/api/djangormm/djangormm/settings.py @@ -35,16 +35,6 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -REST_FRAMEWORK = { - 'DATETIME_FORMAT': "%b-%d-%Y - %H:%M", - - 'DEFAULT_PERMISSION_CLASSES': [ - 'rest_framework.permissions.IsAuthenticated', - ], - 'DEFAULT_AUTHENTICATION_CLASSES': ( - 'knox.auth.TokenAuthentication', - ) -} REST_KNOX = { 'TOKEN_TTL': timedelta(hours=5), diff --git a/install.sh b/install.sh index 0b6be085..b1b97d35 100755 --- a/install.sh +++ b/install.sh @@ -283,6 +283,24 @@ DATABASES = { } } +REST_FRAMEWORK = { + 'DATETIME_FORMAT': "%b-%d-%Y - %H:%M", + + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', + ), + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'knox.auth.TokenAuthentication', + ), +} + +if not DEBUG: + REST_FRAMEWORK.update({ + 'DEFAULT_RENDERER_CLASSES': ( + 'rest_framework.renderers.JSONRenderer', + ) + }) + EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'example@gmail.com'