-
Notifications
You must be signed in to change notification settings - Fork 10
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
No nonce value output #5
Comments
@clarknelson sorry for the late response. When using the view-source option in chrome you probably will see the nonce on the style element. The errors you are seeing are all script related, so you probably forgot to add nonce's to some script tags. If you really can't change that, try config something like this: // content-security-policy.php
<?php
return [
'scriptSrc' => [
"'unsafe-inline'",
],
]; Note: this does kill the point of this plugin, but the errors will go away. |
I'm having a bit of an issue with this one inline script tag: <script type="text/javascript" src="/scripts/manifest.min.js{{ cache }}" nonce="{{ cspNonce('script-src') }}"></script>
<script type="text/javascript" src="/scripts/vendor.min.js{{ cache }}" nonce="{{ cspNonce('script-src') }}"></script>
<script type="text/javascript" src="/scripts/init.min.js{{ cache }}" nonce="{{ cspNonce('script-src') }}"></script>
{% set floorplans = craft.entries().section('floorPlans').with(['floorPlanDetails.floorPlanThumbnail', 'floorPlanDetails.floorPlanGraphic']).all() %}
<script nonce="{{ cspNonce('script-src') }}">
window.floorplans = [{% for floorplan in floorplans %}{
title: '{{ floorplan.title }}',
size: '{{ floorplan.floorPlanSize }}',
sqft: {{ floorplan.floorPlanSqft }},
balcony: '{{ floorplan.floorPlanBalcony }}',
thumbnail: '{{ floorplan.floorPlanDetails[0].floorPlanThumbnail | length > 0 ? floorplan.floorPlanDetails[0].floorPlanThumbnail[0].url }}',
graphic: '{{ floorplan.floorPlanDetails[0].floorPlanGraphic | length > 0 ? floorplan.floorPlanDetails[0].floorPlanGraphic[0].url }}'
},{% endfor %}];
</script> gives me this error:
if I remove the nonce: <script type="text/javascript" src="/scripts/manifest.min.js{{ cache }}" nonce="{{ cspNonce('script-src') }}"></script>
<script type="text/javascript" src="/scripts/vendor.min.js{{ cache }}" nonce="{{ cspNonce('script-src') }}"></script>
<script type="text/javascript" src="/scripts/init.min.js{{ cache }}" nonce="{{ cspNonce('script-src') }}"></script>
{% set floorplans = craft.entries().section('floorPlans').with(['floorPlanDetails.floorPlanThumbnail', 'floorPlanDetails.floorPlanGraphic']).all() %}
<script>
window.floorplans = [{% for floorplan in floorplans %}{
title: '{{ floorplan.title }}',
size: '{{ floorplan.floorPlanSize }}',
sqft: {{ floorplan.floorPlanSqft }},
balcony: '{{ floorplan.floorPlanBalcony }}',
thumbnail: '{{ floorplan.floorPlanDetails[0].floorPlanThumbnail | length > 0 ? floorplan.floorPlanDetails[0].floorPlanThumbnail[0].url }}',
graphic: '{{ floorplan.floorPlanDetails[0].floorPlanGraphic | length > 0 ? floorplan.floorPlanDetails[0].floorPlanGraphic[0].url }}'
},{% endfor %}];
</script> I get two errors:
The first error looks more like the policy I want... Thanks for getting back to me, any help would be appreciated. |
It's for sure the inline scripts that will not load for me. The nonce seems to load fine when included, but it may be changing the policy (see previous comment) |
I output the final CSP value and it looks correct, I am not sure why the errors are showing up:
|
Here is my whole policy:
And the error message:
No idea why the two are different! |
SEOmatic is adding it's own headers, which may conflict with this plugin's settings. Fortunately you can disable at |
There seems to be a difference between inline scripts in the |
@clarknelson I'm looking into it. edit: Duplicate won't work in any way. |
@clarknelson you can disable SEOmatic's nonce option and use the one the CSP plugin provides like this:
I'm not sure if this works fine with template caching (it gave me some issues in my dev environment), but that is something for SEOmatic. |
Thanks for the script, very nice. I'm going to close this since it relates to SEOmatic's added tags. |
Wonder what is going on
The text was updated successfully, but these errors were encountered: