duck.cspยถ

Content-Security utility module.

Module Contentsยถ

Functionsยถ

csp_nonce

Returns the current nonce token for the strict Content-Security-Policy.

refresh_nonce

Refreshes and returns a newly generated nonce value.

Dataยถ

csp_nonce_flag

APIยถ

duck.csp.csp_nonce(request, add_nonce_prefix: bool = False) โ†’ str[source]ยถ

Returns the current nonce token for the strict Content-Security-Policy.

Parameters:
  • request โ€“ The target HTTP request.

  • add_nonce_prefix โ€“ Whether to add the prefix nonce- to the nonce value.

duck.csp.csp_nonce_flagยถ

โ€˜requires-csp-nonceโ€™

duck.csp.refresh_nonce(request) โ†’ str[source]ยถ

Refreshes and returns a newly generated nonce value.