mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
+ Rejecting anonymous in DjangoModelPermissions *before* the .get_queryset call
This commit is contained in:
parent
2ea368e80f
commit
c8773671e7
|
@ -120,6 +120,10 @@ class DjangoModelPermissions(BasePermission):
|
||||||
if getattr(view, '_ignore_model_permissions', False):
|
if getattr(view, '_ignore_model_permissions', False):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if not request.user or (
|
||||||
|
not is_authenticated(request.user) and self.authenticated_users_only):
|
||||||
|
return False
|
||||||
|
|
||||||
if hasattr(view, 'get_queryset'):
|
if hasattr(view, 'get_queryset'):
|
||||||
queryset = view.get_queryset()
|
queryset = view.get_queryset()
|
||||||
assert queryset is not None, (
|
assert queryset is not None, (
|
||||||
|
@ -135,11 +139,7 @@ class DjangoModelPermissions(BasePermission):
|
||||||
|
|
||||||
perms = self.get_required_permissions(request.method, queryset.model)
|
perms = self.get_required_permissions(request.method, queryset.model)
|
||||||
|
|
||||||
return (
|
return request.user.has_perms(perms)
|
||||||
request.user and
|
|
||||||
(is_authenticated(request.user) or not self.authenticated_users_only) and
|
|
||||||
request.user.has_perms(perms)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DjangoModelPermissionsOrAnonReadOnly(DjangoModelPermissions):
|
class DjangoModelPermissionsOrAnonReadOnly(DjangoModelPermissions):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user