Skip to content

Commit

Permalink
disable CSP for django debug view Fixes mozilla#27
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Nov 4, 2013
1 parent c8176ba commit 982cd41
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions csp/middleware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings
from django.utils.six.moves import http_client

from csp.utils import build_policy

Expand All @@ -14,6 +15,11 @@ class CSPMiddleware(object):
"""

def process_response(self, request, response):
# Check for debug view
if response.status_code == http_client.INTERNAL_SERVER_ERROR:
if settings.DEBUG:
return response

if getattr(response, '_csp_exempt', False):
return response

Expand Down

0 comments on commit 982cd41

Please sign in to comment.