@@ -213,6 +213,7 @@ An existing custom middleware, such as this:
213213
214214 from csp.middleware import CSPMiddleware, PolicyParts
215215
216+
216217 class ACustomMiddleware (CSPMiddleware ):
217218
218219 def build_policy (self , request : HttpRequest, response : HttpResponseBase) -> str :
@@ -231,7 +232,7 @@ An existing custom middleware, such as this:
231232 replace = getattr (response, " _csp_replace_ro" , {})
232233 nonce = getattr (request, " _csp_nonce" , None )
233234
234- # ... do custom CSP report only policy logic ...
235+ # ... do custom CSP report- only policy logic ...
235236
236237 return build_policy(config = config, update = update, replace = replace, nonce = nonce)
237238
@@ -246,13 +247,18 @@ can be replaced with this:
246247
247248 class ACustomMiddleware (CSPMiddleware ):
248249
249- def get_policy_parts (self , request : HttpRequest, response : HttpResponseBase, report_only : bool = False ) -> PolicyParts:
250+ def get_policy_parts (
251+ self ,
252+ request : HttpRequest,
253+ response : HttpResponseBase,
254+ report_only : bool = False ,
255+ ) -> PolicyParts:
250256 policy_parts = super ().get_policy_parts(request, response, report_only)
251257
252258 if report_only:
253- # ... do custom CSP report only policy logic ...
259+ ... # do custom CSP report- only policy logic
254260 else :
255- # ... do custom CSP policy logic ...
261+ ... # do custom CSP policy logic
256262
257263 return policy_parts
258264
0 commit comments