Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CSRF exempt piston resource

  • Loading branch information...
commit 713e3970c58934919cc8faf67a09ddfd0a98408a 1 parent a6b96d0
Alex Buchanan authored
Showing with 14 additions and 3 deletions.
  1. +6 −3 apps/subscriptions/urls.py
  2. +8 −0 libs/csrf_exempt_resource.py
View
9 apps/subscriptions/urls.py
@@ -1,14 +1,17 @@
from django.conf.urls.defaults import *
-from piston.resource import Resource
-
from piston.authentication import NoAuthentication
+
+from csrf_exempt_resource import CsrfExemptResource
from .handlers import SubscriptionHandler
+
auth = NoAuthentication()
-subscribe = Resource(handler=SubscriptionHandler, authentication=auth)
+subscribe = CsrfExemptResource(handler=SubscriptionHandler, authentication=auth)
urlpatterns = patterns('',
url('^subscribe/$', subscribe, name='subscriptions.subscribe'),
)
+
+
View
8 libs/csrf_exempt_resource.py
@@ -0,0 +1,8 @@
+from piston.resource import Resource
+
+
+class CsrfExemptResource(Resource):
+ """A Custom Resource that is csrf exempt"""
+ def __init__(self, handler, authentication=None):
+ super(CsrfExemptResource, self).__init__(handler, authentication)
+ self.csrf_exempt = getattr(self.handler, 'csrf_exempt', True)
Please sign in to comment.
Something went wrong with that request. Please try again.