diff --git a/PyRIGS/decorators.py b/PyRIGS/decorators.py index a7c1db90..67d8964c 100644 --- a/PyRIGS/decorators.py +++ b/PyRIGS/decorators.py @@ -58,7 +58,7 @@ def api_key_required(function): try: user_object = models.Profile.objects.get(pk=userid) - except Profile.DoesNotExist: + except models.Profile.DoesNotExist: return error_resp if user_object.api_key != key: diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index d85ff887..3098c3fb 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -12,8 +12,6 @@ https://docs.djangoproject.com/en/1.7/ref/settings/ import os BASE_DIR = os.path.dirname(os.path.dirname(__file__)) -SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') - # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ @@ -27,6 +25,10 @@ TEMPLATE_DEBUG = True ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyrigs.herokuapp.com'] +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') +if not DEBUG: + SECURE_SSL_REDIRECT = True # Redirect all http requests to https + INTERNAL_IPS = ['127.0.0.1'] ADMINS = ( @@ -55,6 +57,7 @@ INSTALLED_APPS = ( MIDDLEWARE_CLASSES = ( 'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware', + 'django.middleware.security.SecurityMiddleware', 'reversion.middleware.RevisionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', diff --git a/RIGS/templates/RIGS/profile_detail.html b/RIGS/templates/RIGS/profile_detail.html index 8fce1e60..e69e7bf0 100644 --- a/RIGS/templates/RIGS/profile_detail.html +++ b/RIGS/templates/RIGS/profile_detail.html @@ -126,7 +126,7 @@
No API Key Generateddiff --git a/templates/base.html b/templates/base.html index c27231bd..3cde5acd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,7 +14,7 @@ -