mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-12-24 07:33:07 +11:00
Fixed CSRF check in API. Closes #94.
This commit is contained in:
parent
cf61cc52d4
commit
6ecde113b6
3 changed files with 3 additions and 4 deletions
|
@ -13,8 +13,7 @@ class SnippetAPITestCase(TestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.api_url = reverse('dpaste_api_create_snippet')
|
||||
self.client = Client()
|
||||
|
||||
self.client = Client(enforce_csrf_checks=True)
|
||||
|
||||
def test_empty(self):
|
||||
"""
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from ..views import APIView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^api/$', APIView.as_view(), name='dpaste_api_create_snippet'),
|
||||
url(r'^api/$', csrf_exempt(APIView.as_view()), name='dpaste_api_create_snippet'),
|
||||
]
|
||||
|
|
|
@ -291,7 +291,6 @@ class APIView(View):
|
|||
"""
|
||||
API View
|
||||
"""
|
||||
@method_decorator(csrf_exempt)
|
||||
def post(self, request, *args, **kwargs):
|
||||
content = request.POST.get('content', '').strip()
|
||||
lexer = request.POST.get('lexer', LEXER_DEFAULT).strip()
|
||||
|
|
Loading…
Reference in a new issue