Commit 840fe7b0 by Tom Christie

Merge pull request #1706 from pipermerriam/piper/use_decorator_mixin_class

Alter CSRF exemption implementation
parents 415b33b4 fc9be55d
...@@ -103,7 +103,9 @@ class APIView(View): ...@@ -103,7 +103,9 @@ class APIView(View):
""" """
view = super(APIView, cls).as_view(**initkwargs) view = super(APIView, cls).as_view(**initkwargs)
view.cls = cls view.cls = cls
return view # Note: session based authentication is explicitly CSRF validated,
# all other authentication is CSRF exempt.
return csrf_exempt(view)
@property @property
def allowed_methods(self): def allowed_methods(self):
...@@ -371,9 +373,9 @@ class APIView(View): ...@@ -371,9 +373,9 @@ class APIView(View):
response.exception = True response.exception = True
return response return response
# Note: session based authentication is explicitly CSRF validated, # Note: Views are made CSRF exempt from within `as_view` as to prevent
# all other authentication is CSRF exempt. # accidental removal of this exemption in cases where `dispatch` needs to
@csrf_exempt # be overridden.
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
""" """
`.dispatch()` is pretty much the same as Django's regular dispatch, `.dispatch()` is pretty much the same as Django's regular dispatch,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment