Commit 1ec165f3 by Tom Christie

`OPTIONS` is also a safe method.

parent 24911f37
...@@ -20,6 +20,8 @@ __all__ = ( ...@@ -20,6 +20,8 @@ __all__ = (
'PerResourceThrottling' 'PerResourceThrottling'
) )
SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS']
_403_FORBIDDEN_RESPONSE = ErrorResponse( _403_FORBIDDEN_RESPONSE = ErrorResponse(
status.HTTP_403_FORBIDDEN, status.HTTP_403_FORBIDDEN,
...@@ -84,8 +86,7 @@ class IsUserOrIsAnonReadOnly(BasePermission): ...@@ -84,8 +86,7 @@ class IsUserOrIsAnonReadOnly(BasePermission):
def check_permission(self, user): def check_permission(self, user):
if (not user.is_authenticated() and if (not user.is_authenticated() and
self.view.method != 'GET' and self.view.method not in SAFE_METHODS):
self.view.method != 'HEAD'):
raise _403_FORBIDDEN_RESPONSE raise _403_FORBIDDEN_RESPONSE
......
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