You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing so, it actually never checks the permissions because of the MRO. The dispatch method from the View class will be called and because it doesn't call the super method, PermissionRequiredMixin.dispatch is silently skipped.
This can very easily lead to security concerns.
Would it make sens to add a rule to django-upgrade swapping the base classes automatically if the PermissionRequiredMixin is not the first base class ? Or does such feature makes more sense as a linter rule via flake8/ruff ?
Description
Hey Adam!
A common gotcha when using
PermissionRequiredMixin
is to place it last in your subclass hierarchy for ex:Doing so, it actually never checks the permissions because of the MRO. The
dispatch
method from theView
class will be called and because it doesn't call the super method,PermissionRequiredMixin.dispatch
is silently skipped.This can very easily lead to security concerns.
Would it make sens to add a rule to
django-upgrade
swapping the base classes automatically if thePermissionRequiredMixin
is not the first base class ? Or does such feature makes more sense as a linter rule via flake8/ruff ?Ref: https://stackoverflow.com/questions/54959548/django-permissionrequiredmixin-permission-required-not-working
The text was updated successfully, but these errors were encountered: