Download the PHP package hotchand/module-csp-manager without Composer

On this page you can find all versions of the php package hotchand/module-csp-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package module-csp-manager

Hotchand_CspManager

Magento 2 Content Security Policy (CSP) Whitelist Manager

A Magento 2 module that lets store administrators manage Content Security Policy whitelists, SHA-256 inline script hashes, and per-directive domain allowlists directly from the Magento admin panel without touching code or XML files.


The Problem

Magento 2.4+ enforces strict Content Security Policy (CSP) headers by default. Any third-party script, image, font, or API call that isn't explicitly whitelisted produces browser console errors like:

The native solution requires developers to create or edit csp_whitelist.xml files and redeploy static content every time a new domain needs to be allowed. This is slow and requires developer access.


The Solution

Hotchand_CspManager exposes a full CSP management UI under:

Add or remove domains for any CSP directive, paste inline script SHA-256 hashes from your browser console, and set your store's own domain for image whitelisting — all without touching a single file or running a deployment.


Features


Pre-configured Third-Party Services

The module ships with defaults covering the most common services that trigger CSP violations:

Category Services
Analytics Google Analytics, Google Tag Manager, Adobe Analytics
Advertising Google Ads, DoubleClick, Facebook Pixel, Bing Ads, TikTok Pixel
Payments PayPal, Stripe, Klarna, Amazon Pay, Cardinal Commerce (3DS)
Support Tawk.to, Disqus
Fonts & CDN Google Fonts, Typekit, Cloudflare, jsDelivr
Video YouTube, Vimeo
Reviews Trustpilot, Trusted Shops
New Relic Browser agent, data ingest
CMP Usercentrics
Stape Server-side GTM proxy

Requirements

Dependency Version
PHP 8.1 or higher
Magento Open Source / Adobe Commerce 2.4.4 – 2.4.8
Magento_Csp module Included in Magento 2.4+

Installation

Composer (Recommended)

Manual Installation

  1. Create the directory app/code/Hotchand/CspManager/
  2. Copy all module files into that directory
  3. Run the following commands from your Magento root:

Configuration

Navigate to Stores → Configuration → Hotchand → CSP Whitelist Manager.

General

Field Description
Enable CSP Whitelist Manager Master on/off switch

Inline Script Hashes

Fixes Executing inline script violates the following Content Security Policy directive errors.

How to find the hash:

  1. Open your browser's developer console
  2. Look for a CSP error message ending in: ...a hash ('sha256-XXXXXXX='), or a nonce is required
  3. Copy the full sha256-XXXXXXX= string
  4. Paste it into the SHA-256 Inline Script Hashes field — one per line

Directives

Each directive has its own textarea. Format rules:

Directive Controls
script-src JavaScript files and inline scripts
img-src Images, favicons, tracking pixels
connect-src XHR, fetch(), WebSocket, EventSource
style-src External CSS stylesheets
font-src Web fonts
frame-src <iframe> embeds
media-src <audio> and <video> elements

Image Sources — Store Domain Field

If your store's own images (wysiwyg, media) are being blocked despite 'self' being in the policy, enter your domain here:

This explicitly adds your domain as a host source in img-src, which resolves a known edge case in Magento 2.4.x where dynamically loaded images are not covered by 'self'.


Architecture

The module implements Magento\Csp\Api\PolicyCollectorInterface and registers itself into Magento's CompositePolicyCollector via di.xml.

Key class: Hotchand\CspManager\Model\CspPolicyCollector


Module Structure


Troubleshooting

Changes not taking effect

Flush the Magento cache after saving configuration:

If you are using Varnish or full-page cache, also purge that.

A domain I added is still being blocked

  1. Make sure you added it to the correct directive. A script blocked under script-src won't be fixed by adding it to img-src.
  2. Check that the domain format is correct — include the subdomain if the error URL has one.
  3. If the error is about an inline script (not an external URL), it needs a SHA-256 hash, not a domain.

Inline script hash still blocked after adding it

Make sure you copied the full string including the sha256- prefix and the trailing =:

Same-domain images blocked (Magebig, wysiwyg)

Enter your store's domain (without https://) in the Image Sources → Store Domain field and flush cache.


Frequently Asked Questions

Does this replace Magento's native CSP system? No. It merges with it. Domains from csp_whitelist.xml files across all modules are preserved. This module adds on top.

Will this work on Magento Cloud / Adobe Commerce Cloud? Yes. The module uses Magento's standard config and DI systems with no file system writes at runtime.

Is there a performance impact? Minimal. The module reads from the Magento config cache on each request. No external HTTP calls are made.

Can I use this per store view? Yes. All fields support Default / Website / Store View scope.

What happens if I disable the module? Only the domains configured in this module's admin panel are removed from CSP headers. Native csp_whitelist.xml policies from Magento core and other modules continue to apply normally.


Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m 'Add my feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Open a Pull Request

License

MIT License


Author

Hotchand Sajnani Senior PHP / Magento Engineer ConnectResale LLC


Changelog

1.0.0 — 2026-01-01


All versions of module-csp-manager with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
magento/framework Version >=103.0.0
magento/module-csp Version >=1.0.0
magento/module-store Version >=101.0.0
magento/module-config Version >=101.0.0
magento/module-backend Version >=101.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hotchand/module-csp-manager contains the following files

Loading the files please wait ...