Closed S1SYPHOS closed 3 years ago
@bnomei any idea? I guess I'm doing something wrong - smells fishy ..
what means "does not work"? is the string not printed? otherwise most modern browsers do not allow styles with nonces IF a hash is set in CSP headers.
some console error like this should be visible
Refused to execute inline script because it violates the following Content Security Policy directive
Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.
and the csp plugin does set at least one hash (the kirby panel one)
I guess disabling the panel nonce generation would be the way to go then. From a frontend perspective, it seems optional to have a panel nonce imho
Will report back later!
what means "does not work"? is the string not printed? otherwise most modern browsers do not allow styles with nonces IF a hash is set in CSP headers.
some console error like this should be visible
Refused to execute inline script because it violates the following Content Security Policy directive
Is it therefore impossible to secure <style>
tags with nonces only? I don't see how that would be done ..
some information about unsafe scripts/stlyes and nonces...
see this issue https://github.com/bnomei/kirby3-security-headers/issues/23 if you set a nonce you can not have unsafe inline script/style.
the plugin will set
1) a nonce from panel (if enabled) and
2) using bnomei.securityheader.seed
a nonce for site()->nonce()
. so to have unsave inline script/style by default. you need to set seed
to false
.
Thanks @bnomei !
Hey there, when playing around with your plugin, I noticed that
$site->nonce()
works for CSS files (via<link>
tag) and JS files (via<script>
tag), but not for inline CSS via<style>
- which is odd ..My code looks like this:
The only part failing me is
<style nonce="<?= $site->nonce() ?>"><?= $css ?></style>
- which I cannot explain ..