Browse files

[1.6.x] Fixed #18923 -- Corrected usage of sensitive_post_parameters …

…in contrib.auth

Thanks Collin Anderson for the report.

Backport of 425d076 from master
  • Loading branch information...
1 parent 4e7745c commit 97254154ab43d7973fba09ccd7ab548866f83e03 @timgraham timgraham committed Aug 2, 2013
Showing with 9 additions and 2 deletions.
  1. +3 −2 django/contrib/auth/admin.py
  2. +6 −0 django/views/decorators/debug.py
View
5 django/contrib/auth/admin.py
@@ -17,6 +17,7 @@
from django.views.decorators.debug import sensitive_post_parameters
csrf_protect_m = method_decorator(csrf_protect)
+sensitive_post_parameters_m = method_decorator(sensitive_post_parameters())
class GroupAdmin(admin.ModelAdmin):
@@ -90,7 +91,7 @@ def lookup_allowed(self, lookup, value):
return False
return super(UserAdmin, self).lookup_allowed(lookup, value)
- @sensitive_post_parameters()
+ @sensitive_post_parameters_m
@csrf_protect_m
@transaction.atomic
def add_view(self, request, form_url='', extra_context=None):
@@ -121,7 +122,7 @@ def add_view(self, request, form_url='', extra_context=None):
return super(UserAdmin, self).add_view(request, form_url,
extra_context)
- @sensitive_post_parameters()
+ @sensitive_post_parameters_m
def user_change_password(self, request, id, form_url=''):
if not self.has_change_permission(request):
raise PermissionDenied
View
6 django/views/decorators/debug.py
@@ -1,5 +1,7 @@
import functools
+from django.http import HttpRequest
+
def sensitive_variables(*variables):
"""
@@ -62,6 +64,10 @@ def my_view(request)
def decorator(view):
@functools.wraps(view)
def sensitive_post_parameters_wrapper(request, *args, **kwargs):
+ assert isinstance(request, HttpRequest), (
+ "sensitive_post_parameters didn't receive an HttpRequest. If you "
+ "are decorating a classmethod, be sure to use @method_decorator."
+ )
if parameters:
request.sensitive_post_parameters = parameters
else:

0 comments on commit 9725415

Please sign in to comment.