Skip to content

Conversation

Debatty-Tom
Copy link
Contributor

@Debatty-Tom Debatty-Tom commented Oct 8, 2025

Cover #46 by adding csp option on default script tag.

By setting CSP_ENABLE=true in your .env file, this package provides access to a nonce in the default script tag. The CSP_ENABLE flag is also used by Spatie’s laravel-csp package.

A CSP nonce should consist of at least 16 bytes of cryptographically secure random data, and be safe for use in HTML attributes and HTTP headers. I chose to use bin2hex() instead of base64_encode() because it can generate characters that are unsafe for these contexts.

Since a csp_nonce() helper does not exist by default, I implemented a custom one.

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.

1 participant