Skip to content

Include CSP nonce in header for streaming responses - #289

Open
robhudson wants to merge 3 commits into
mainfrom
streaming-nonce
Open

robhudson wants to merge 3 commits into
mainfrom
streaming-nonce

Conversation

@robhudson

Copy link
Copy Markdown
Collaborator

Streaming responses (StreamingHttpResponse, FileResponse) could send a CSP header without the nonce, because the body is rendered after the middleware writes the header. The middleware now generates the nonce for streaming responses before writing the header. This ports Django's fix for the same bug (#37419).

Streaming responses now always include a nonce in the header. Browsers ignore 'unsafe-inline' when a nonce is present, so policies combining NONCE and UNSAFE_INLINE in one directive may now block inline styles or scripts. This is documented in docs/nonce.rst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant