Skip to content

Add nonce to <script> elements #1464

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

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

Yannik
Copy link
Contributor

@Yannik Yannik commented Sep 18, 2023

This PR adds the configured nonce to <script> elements (or nothing, it no nonce is set, since getNonceAttribute will then return an empty string).

This does not fix all of the csp issues (embedded fonts, third party assets), but it atleast makes laravel-debugbar usable with a configured content security policy.

To set the nonce, you can use Debugbar::getJavascriptRenderer()->setCspNonce($yourNonce);

@Yannik Yannik force-pushed the add-nonce-to-script-elements branch from b31f59e to 66ab403 Compare September 19, 2023 09:46
@Yannik
Copy link
Contributor Author

Yannik commented Sep 19, 2023

Combined with php-debugbar/php-debugbar#561 (which has been merged), this fixes all script-src csp issues! style-src 'unsafe-inline' is still required, since there are a few inline styles where I haven't found a good solution yet.

@barryvdh barryvdh merged commit 8a3bab7 into barryvdh:master Sep 19, 2023
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.

2 participants