diff --git a/mellon/middleware.py b/mellon/middleware.py index 2a31a21..6dbc584 100644 --- a/mellon/middleware.py +++ b/mellon/middleware.py @@ -37,6 +37,9 @@ class PassiveAuthenticationMiddleware(MiddlewareClass): # Skip AJAX requests if request.is_ajax(): return + # Skip AJAX and media/script requests, unless mellon_no_passive is False on the view + if getattr(view_func, 'mellon_no_passive', True) and 'text/html' not in request.META.get('HTTP_ACCEPT', ''): + return # Skip views asking to be skiped if getattr(view_func, 'mellon_no_passive', False): return