Magento 2 Content Security Policy (CSP) Whitelist Manager

Installation and User Guide for Magento 2 Content Security Policy (CSP) Whitelist Manager

Table of Contents

  1. Installation
    • Download Extension
    • Installation via app/code
    • Installation via Composer
  2. Configuration Settings for Content Security Policy (CSP) Whitelist
    • General Settings
    • CSP Directives
    • Critical Security Overrides
  3. CSP Reports Grid
  4. Working of the extension
    • Steps to Check and Fix Console CSP Errors through CSP Grid
    • Steps to Check and Fix Console CSP Errors
  5. Fixing Inline Script and Inline Style Content Security Policy Issues
    • Inline Style Error Example
    • Inline Script Error Example

Installation

image (7).png

https://docs.scommerce-mage.com/magento-2-extensions/installation-via-composer/installation-via-composer

Configuration Settings for Content Security Policy (CSP) Whitelist

Go to Admin > Stores > Configuration > Scommerce Configuration > CSP Whitelist

General Settings

image (12).png

CSP Directives

image (13).png

image (14).png

image (15).png

image (16).png

image (17).png

image (9).png

image (18).png

image (19).png

image (20).png

image (21).png

image (22) (1).png

image (23) (1).png

image (23).png

image (24).png

Critical Security Overrides

Caution: Enabling unsafe inline scripts is a temporary measure and should only be done under the guidance of your developer. You must ask your developers or third party extension providers to whitelist their inline scripts. This setting must NOT be left on 'YES' permanently, as it significantly increases the risk of security vulnerabilities, making your site an easy target for attackers. Always prioritise the security of your site and user data.

image (24) (1).png

CSP Reports Grid

The CSP Reports Grid collects and displays all the CSP errors on both frontend and backend. To enable report collection please make sure to add the following URLs in Security > CSP section of your Store config:-

image (25).png

To access the grid go to Admin>System>Scommerce CSP Records> CSP Report Only Grid

image (26).png

Working of the extension

Steps to Check and Fix Console CSP Errors thorugh CSP Reports Grid

Go to Admin>System>Scommerce CSP Records> CSP Report Only Grid, select the error records that you want to whitelist then from the Actions dropdown, select whitelist.

image (27).png

Please clear caches as prompted:-

image (28).png

Once done all the selected entries will be whitelisted into their specific CSP directive and should be visible in the admin configuration.

image (30).png

Note:- If you have already whitelisted the entries manually in the configuration then you can delete these records from the grid by selection the records that you want to delete and then click on Action dropdown and select delete.

image (31).png

Steps to Check and Fix Console CSP Errors Manually

image (32).png

image (33).png

image (29).png

image (34).png

image (34) (2).png

Fixing Inline Script and Inline Style Content Security Policy Issues

In this section, we will show you how to fix the inline script and style related console errors for Content Security Policy. Please check the image below:

image (35).png

Let us look at examples to understand this process better:

Inline Style Error Example

<style>
body {
background-color: #f3f3f3;
}
</style>

image (35) (1).png

image (36).png

Inline Script Error Example

<script>
console.log('Hello, world!');
</script>

image (36) (1).png

image (37).png

If you have a question related to this extension please check out our FAQ Section first. If you can't find the answer you are looking for then please contact support@scommerce-mage.com.


Revision #6
Created 12 May 2025 11:40:41 by scommerce
Updated 24 October 2025 09:42:44 by scommerce