mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-09 16:10:50 +03:00
OPTIONS
is also a safe method.
This commit is contained in:
parent
24911f37e4
commit
1ec165f38c
|
@ -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):
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user