diff options
| author | Tom Christie | 2015-02-13 13:38:44 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-02-13 13:38:44 +0000 |
| commit | 4248a8d3fc725d9ae3fe7aaaad7ee12479ab07ab (patch) | |
| tree | c38485aec717a35de8691c3d55bd50ba3e4aae6d /rest_framework/permissions.py | |
| parent | 84260b5dd66cc31858898ff11d5300a73083cca1 (diff) | |
| parent | ad32e14360a23ee3e93ff54ca206c64009d184c9 (diff) | |
| download | django-rest-framework-4248a8d3fc725d9ae3fe7aaaad7ee12479ab07ab.tar.bz2 | |
Merge pull request #2198 from tomchristie/version-3.1
Version 3.1
Diffstat (limited to 'rest_framework/permissions.py')
| -rw-r--r-- | rest_framework/permissions.py | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/rest_framework/permissions.py b/rest_framework/permissions.py index 3f6f5961..9069d315 100644 --- a/rest_framework/permissions.py +++ b/rest_framework/permissions.py @@ -3,8 +3,7 @@ Provides a set of pluggable permission policies. """ from __future__ import unicode_literals from django.http import Http404 -from rest_framework.compat import (get_model_name, oauth2_provider_scope, - oauth2_constants) +from rest_framework.compat import get_model_name SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS'] @@ -199,28 +198,3 @@ class DjangoObjectPermissions(DjangoModelPermissions): return False return True - - -class TokenHasReadWriteScope(BasePermission): - """ - The request is authenticated as a user and the token used has the right scope - """ - - def has_permission(self, request, view): - token = request.auth - read_only = request.method in SAFE_METHODS - - if not token: - return False - - if hasattr(token, 'resource'): # OAuth 1 - return read_only or not request.auth.resource.is_readonly - elif hasattr(token, 'scope'): # OAuth 2 - required = oauth2_constants.READ if read_only else oauth2_constants.WRITE - return oauth2_provider_scope.check(required, request.auth.scope) - - assert False, ( - 'TokenHasReadWriteScope requires either the' - '`OAuthAuthentication` or `OAuth2Authentication` authentication ' - 'class to be used.' - ) |
