diff --git a/dpaste/disable.py b/dpaste/disable.py deleted file mode 100644 index 5e0795a..0000000 --- a/dpaste/disable.py +++ /dev/null @@ -1,3 +0,0 @@ -class DisableCSRF(object): - def process_request(self, request): - setattr(request, '_dont_enforce_csrf_checks', True) diff --git a/dpaste/settings/__init__.py b/dpaste/settings/__init__.py index 185ab4a..63e3e39 100644 --- a/dpaste/settings/__init__.py +++ b/dpaste/settings/__init__.py @@ -83,7 +83,7 @@ LOGIN_REDIRECT_URL = '/' #============================================================================== MIDDLEWARE_CLASSES = ( - 'dpaste.disable.DisableCSRF', + 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', diff --git a/dpaste/templates/dpaste/about.html b/dpaste/templates/dpaste/about.html index c7c3839..ddf70b3 100644 --- a/dpaste/templates/dpaste/about.html +++ b/dpaste/templates/dpaste/about.html @@ -72,6 +72,7 @@

+ {% csrf_token %}
diff --git a/dpaste/views.py b/dpaste/views.py index 629608f..1a757d0 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -14,6 +14,7 @@ from django.core.urlresolvers import reverse from django.db.models import Count from django.views.defaults import (page_not_found as django_page_not_found, server_error as django_server_error) +from django.views.decorators.csrf import csrf_exempt from dpaste.forms import SnippetForm from dpaste.models import Snippet @@ -265,6 +266,7 @@ FORMAT_MAPPING = { 'json': _format_json, } +@csrf_exempt def snippet_api(request): content = request.POST.get('content', '').strip() lexer = request.POST.get('lexer', LEXER_DEFAULT).strip()