From 18aa6546e9da5055eb7e39e374985a120a3b3abe Mon Sep 17 00:00:00 2001 From: Branson Stephens <branson.stephens@ligo.org> Date: Tue, 12 Aug 2014 12:55:47 -0500 Subject: [PATCH] Added guardian to installed apps and added ANONYMOUS_USER_ID=-1 and GUARDIAN_RENDER_403=True to settings. --- settings/branson.py | 28 ++++++++++++++-------------- settings/default.py | 10 ++++++++++ templates/403.html | 9 +++++++++ 3 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 templates/403.html diff --git a/settings/branson.py b/settings/branson.py index 1e6dbcc70..ba822b2ca 100644 --- a/settings/branson.py +++ b/settings/branson.py @@ -66,20 +66,20 @@ MIDDLEWARE_CLASSES = [ # 'debug_toolbar.middleware.DebugToolbarMiddleware', ] -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.admin', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.staticfiles', - 'gracedb', - 'userprofile', - 'ligoauth', - 'rest_framework', - 'south', -# 'debug_toolbar', -) +#INSTALLED_APPS = ( +# 'django.contrib.auth', +# 'django.contrib.admin', +# 'django.contrib.contenttypes', +# 'django.contrib.sessions', +# 'django.contrib.sites', +# 'django.contrib.staticfiles', +# 'gracedb', +# 'userprofile', +# 'ligoauth', +# 'rest_framework', +# 'south', +## 'debug_toolbar', +#) #INTERNAL_IPS = ( # '129.89.61.55', diff --git a/settings/default.py b/settings/default.py index 2ca3af00a..fb51ddb7d 100644 --- a/settings/default.py +++ b/settings/default.py @@ -183,8 +183,12 @@ AUTHENTICATION_BACKENDS = ( # 'ligoauth.middleware.auth.RemoteUserBackend', # 'ligodjangoauth.LigoShibbolethAuthBackend', # 'django.contrib.auth.backends.ModelBackend', + 'guardian.backends.ObjectPermissionBackend', ) +ANONYMOUS_USER_ID = -1 +GUARDIAN_RENDER_403 = True + SHIB_AUTHENTICATION_SESSION_INITIATOR = 'https://moe.phys.uwm.edu/Shibboleth.sso/Login' # If these are left at default, when the Shibboleth middleware @@ -227,6 +231,7 @@ INSTALLED_APPS = ( 'ligoauth', 'rest_framework', 'south', + 'guardian', ) REST_FRAMEWORK = { @@ -244,6 +249,11 @@ STATICFILES_FINDERS = ( STATICFILES_DIRS = () +# Added in order to perform data migrations on the auth app +SOUTH_MIGRATION_MODULES = { + 'auth' : 'migrations.auth', +} + # XXX The following Log settings are for a performance metric. import logging LOG_ROOT = '/home/gracedb/logs' diff --git a/templates/403.html b/templates/403.html new file mode 100644 index 000000000..cb14e96e8 --- /dev/null +++ b/templates/403.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block title %}403 – Forbidden{% endblock %} +{% block heading %}Forbidden {{ object.graceid }}{% endblock %} + +{% block content %} + <p>You do not have the required permissions for the requested action.</p> + {{ message|safe }} +{% endblock %} -- GitLab