aboutsummaryrefslogtreecommitdiffstats
path: root/djangorestframework/permissions.py
diff options
context:
space:
mode:
authorTom Christie2012-02-11 18:43:58 +0000
committerTom Christie2012-02-11 18:43:58 +0000
commit1ec165f38c508d7ac4c158ec8d558c5d8f1bd15b (patch)
treeccb6a30ca86172f725b3d75d347d901672233290 /djangorestframework/permissions.py
parent24911f37e47d7350b33d43342ce7662504e634df (diff)
downloaddjango-rest-framework-1ec165f38c508d7ac4c158ec8d558c5d8f1bd15b.tar.bz2
`OPTIONS` is also a safe method.
Diffstat (limited to 'djangorestframework/permissions.py')
-rw-r--r--djangorestframework/permissions.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/djangorestframework/permissions.py b/djangorestframework/permissions.py
index de24e23b..2d6d8922 100644
--- a/djangorestframework/permissions.py
+++ b/djangorestframework/permissions.py
@@ -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