I am trying to remove "unsafe-inline" from Content-Security-Policy script-src directive and facing errors while loading them to site. console error says need to add hash or nonce. adding as hash integrity seems to work for few scripts but launch script and few other scripts are still showing errors.
went through above documents , but not able to get complete understanding on how to generate nonce and add it to scripts and Content-Security-Policy in dispatcher dynamically .
Please advice . Thank you
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Vishnu9,
nonce is supposed to be an unguessable, random value that the server generates individually for each response. Therefore I suggest you define your CSP header in the AEM Publish, instead of Dispatcher.
Here are the high-level steps to follow:
Good luck,
Daniel
Views
Replies
Total Likes
@Vishnu9 Adding content-security-policy directly at dispacher level is not best practice. You may have to add it on server level. In your case on publisher instance.
Sample policy https://experienceleague.adobe.com/en/docs/experience-platform/tags/client-side/content-security-pol...
content-security-policy:
default-src 'none';
object-src 'self';
script-src 'self';
connect-src 'self';
img-src 'self' ;
font-src 'self';
media-src 'self';
You can add the configuration in Sling main servlet. additional headers,
sling.additional.response.headers
https://www.javadoc.io/static/org.apache.sling/org.apache.sling.engine/2.3.8/index.html?org/apache/s...
Hope that helps.
Views
Replies
Total Likes
Views
Likes
Replies