Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for strict Content-Security-Policy to flask-admin #1839

Closed
pogliamarci opened this issue Apr 3, 2019 · 1 comment
Closed

Add support for strict Content-Security-Policy to flask-admin #1839

pogliamarci opened this issue Apr 3, 2019 · 1 comment

Comments

@pogliamarci
Copy link

Flask-admin can't be used with "strict" content security policy (https://csp.withgoogle.com/docs/strict-csp.html), i.e., with content-security-policy headers that allow scripts based on a nonce rather than on a whitelist of origins. Given that nonce-based CSPs are the recommended way to use CSP, it would be nice if flask-admin supported them.

To be compatible, it needs:

  • a way to specify a nonce to be added to <script> tags.
    The nonce is generated at every request by the extension that handles the CSP header (e.g., flask-talisman sets the csp_nonce attribute in flask.request and defines a function csp_nonce() in the jinja globals).
  • to remove inline javascript and event handlers. I cursorily looked at those, and it seems that at least for the bootstrap3 template, there are just a handful of <a href="javascript:void(0)"> that could be migrated to <a href="#">

This is related to #1135 (both refer to Content-Security-Policy compatibility), this addresses a different problem (compatibility with nonce-based CSPs, rather than removal of inline Javascript).

I may work at a PR for this (no guarantee).

@samuelhwilliams
Copy link
Contributor

Thanks for reporting this issue. As there are a few issues open on the topic of CSP, I'm go to close this one in favour of #2344, so that we can keep conversation in one place.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants