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

Widgets do not work with CSP #82

Open
Lapeth opened this issue Jul 15, 2024 · 0 comments
Open

Widgets do not work with CSP #82

Lapeth opened this issue Jul 15, 2024 · 0 comments

Comments

@Lapeth
Copy link

Lapeth commented Jul 15, 2024

Content Security Policy (CSP) requires that all script tags be marked with a nonce attribute. Libraries such as django-csp lets us insert this in templates. Django-tempus-dominus inserts a script tag without a nonce, blocking the resource from being used by the browser.

Clunky workaround:
Write script tags as necessary including the nonce:

<script type="text/javascript" nonce="{{request.csp_nonce}}">
    new tempusDominus.TempusDominus(
        document.getElementById("id_datetime")
    );
</script>
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