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

Generate nonce value for CSP header #13

Merged
merged 2 commits into from
Jan 13, 2018
Merged

Generate nonce value for CSP header #13

merged 2 commits into from
Jan 13, 2018

Conversation

barryvanveen
Copy link
Contributor

Config

The CSP header allows for nonce-values on the style-src and script-src directives. Both these directives have a new configuration option:

'add-generated-nonce' => true,

This option will generate a unique and secure nonce value for that request and add it to the nonces of that directive.

Usage

The generated nonce can be used to "whitelist" unsafe (i.e. inline and eval) styles and scripts.

Retrieve the nonce for this request:

$nonce = SecureHeaders::nonce();

Set the nonce-attribute on the script or style tag:

<style type="text/css" nonce="{{$nonce}}">
  // ...
</style>
<script type="text/javascript" nonce="{{$nonce}}">
  // ....
</script>

@barryvanveen
Copy link
Contributor Author

Hi @bepsvpt,

This PR is for the enhancement I mentioned in https://github.com/BePsvPT/csp-builder/issues/1. Please let me know if I can help out in any way!

Regards,

Barry

@bepsvpt bepsvpt merged commit b5236e7 into bepsvpt:master Jan 13, 2018
@bepsvpt
Copy link
Owner

bepsvpt commented Jan 13, 2018

@barryvanveen thanks a lot!

@barryvanveen
Copy link
Contributor Author

Hi @bepsvpt,

Can you tag a new release so we can start working with nonces? :)

@bepsvpt
Copy link
Owner

bepsvpt commented Mar 11, 2018

@barryvanveen sorry for not releasing a new version so long. I had tagged a new version. :)

@barryvanveen
Copy link
Contributor Author

Not a problem at all, thank you!

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