##// END OF EJS Templates
Merge branch csp into 3.x...
Merge branch csp into 3.x Add APIHandler

File last commit:

r21469:b15ba97b
r21487:7222bd53 merge
Show More
handlers.py
23 lines | 707 B | text/x-python | PythonLexer
Kyle Kelley
Log CSP violations via report
r19141 """Tornado handlers for security logging."""
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
from tornado import gen, web
Min RK
Add APIHandler base class...
r21469 from ...base.handlers import APIHandler, json_errors
Kyle Kelley
One unified CSP report URI
r19148 from . import csp_report_uri
Kyle Kelley
Handle CSP Reports
r19140
Min RK
Add APIHandler base class...
r21469 class CSPReportHandler(APIHandler):
Kyle Kelley
Handle CSP Reports
r19140 '''Accepts a content security policy violation report'''
@web.authenticated
@json_errors
def post(self):
'''Log a content security policy violation report'''
csp_report = self.get_json_body()
Kyle Kelley
Log warning directly.
r19156 self.log.warn("Content security violation: %s",
self.request.body.decode('utf8', 'replace'))
Kyle Kelley
Handle CSP Reports
r19140
default_handlers = [
(csp_report_uri, CSPReportHandler)
]