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

Can we add nonce support for django-csp? #1241

Open
sshishov opened this issue May 21, 2024 · 1 comment
Open

Can we add nonce support for django-csp? #1241

sshishov opened this issue May 21, 2024 · 1 comment

Comments

@sshishov
Copy link

sshishov commented May 21, 2024

Describe the bug
Hi, we are trying to implement the Strict CSP policy meaning we do not allow unsafe-inline and require strict-dynamic

To Reproduce
When we are trying to render the page, we are getting:

Swagger:
- Refused to load the stylesheet 'https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest/swagger-ui.css'
- Refused to load the script 'https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest/swagger-ui-bundle.js'
- Refused to load the script 'https://cdn.jsdelivr.net/npm/swagger-ui-dist@latest/swagger-ui-standalone-preset.js'
- Refused to execute inline script because it violates... (inline script with 'swaggerSettings' etc)
Redoc:
- Refused to load the script 'https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js'

Expected behavior
No CSP errors should happen when using strict-dynamic with support of CSP

NOTE: I have manually added it in the file using <script nonce="{{request.csp_nonce}}" ...> and it was working like a charm.
I guess nowdays if you are using CSP, it is django-csp therefore it is good to add the support for it. Also maybe in future it will become the django standard library.

NOTE: if django-csp is not used, it still should be acceptable as people will be able to add either Host-based exclusion or allow unsafe-inline alltogether.

What do you think?

@sshishov
Copy link
Author

Additional information: redoc has added nonce support already.

Changelog: https://github.com/Redocly/redoc/blob/main/CHANGELOG.md#200-rc66-2022-03-30

PR: Redocly/redoc#1566

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

No branches or pull requests

1 participant