mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 13:14:30 +03:00
OPTIONS
is also a safe method.
This commit is contained in:
parent
24911f37e4
commit
1ec165f38c
|
@ -20,6 +20,8 @@ __all__ = (
|
|||
'PerResourceThrottling'
|
||||
)
|
||||
|
||||
SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS']
|
||||
|
||||
|
||||
_403_FORBIDDEN_RESPONSE = ErrorResponse(
|
||||
status.HTTP_403_FORBIDDEN,
|
||||
|
@ -84,8 +86,7 @@ class IsUserOrIsAnonReadOnly(BasePermission):
|
|||
|
||||
def check_permission(self, user):
|
||||
if (not user.is_authenticated() and
|
||||
self.view.method != 'GET' and
|
||||
self.view.method != 'HEAD'):
|
||||
self.view.method not in SAFE_METHODS):
|
||||
raise _403_FORBIDDEN_RESPONSE
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user