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

OTP field doesn't render properly with style CSP configured to self #143

Open
vriviere-odin opened this issue Apr 29, 2024 · 0 comments
Open

Comments

@vriviere-odin
Copy link

vriviere-odin commented Apr 29, 2024

Problem:

Django-otp seems to add some inline styling to correctly render the OTP field in /admin. If CSP are configured to block any inline style, the follow errors is returned and the field doesn't render as it should:

Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-....='), or a nonce ('nonce-...') is required to enable inline execution.

Same happen once logged in, when clicking the qrcode link, there is some inline style:

<div style="text-align: center;">
  <p id="qrcode">
    <img width="200" height="200"
         style="background-color: white"
         ...

Solution:

Add a hash or make the inline script safe (if it doesn't change often) or use a style.css file and import it instead.

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