PHPackages                             baldwin/magento2-module-csp-shim - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. baldwin/magento2-module-csp-shim

ActiveMagento2-module

baldwin/magento2-module-csp-shim
================================

Magento 2 module which replaces the default Magento CSP module and effectively disables its functionality

v1.0.11(2mo ago)34105.5k↑23.6%5[1 issues](https://github.com/baldwin-agency/magento2-module-csp-shim/issues)1MITPHPPHP ~7.4.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

Since May 23Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/baldwin-agency/magento2-module-csp-shim)[ Packagist](https://packagist.org/packages/baldwin/magento2-module-csp-shim)[ RSS](/packages/baldwin-magento2-module-csp-shim/feed)WikiDiscussions v1 Synced 1mo ago

READMEChangelog (10)DependenciesVersions (17)Used By (1)

CSP shim module for Magento 2
=============================

[](#csp-shim-module-for-magento-2)

Purpose
-------

[](#purpose)

This module exists for people who don't want to deal with the CSP (Content-Security-Policy) module which ships with Magento.

Up until Magento 2.4.7, it was simple, you could just remove the module via composer's `replace` syntax. But in Magento 2.4.7, this module is more tightly integrated with certain modules (like the AdminAnalytics, Checkout and Paypal modules), which - when you try to remove the CSP module using composer's `replace` syntax - would cause `bin/magento setup:di:compile` to fail.

This module provides a solution for this case, by pretending to be the Magento CSP module for certain classes that some other modules require. The classes introduced by this module use the Magento namespace because there doesn't seem to be another way of doing this but the classes are actually empty and only contain empty functions just so nothing crashes when other modules call them.

This module comes bundled with the composer `replace` line to remove the Magento CSP module, so you don't need to do this yourself anymore.

**Update 12 June 2024**: Magento devs decided to backport the CSP changes to the following Magento security releases, so we now also support these versions in the shim:

- 2.4.4-p9
- 2.4.5-p8
- 2.4.6-p6

Alternatives
------------

[](#alternatives)

This module might not be the best solution out there (3rd party modules might try to use classes which we don't provide in this module), so here are some alterntives we can also recommend that don't remove the CSP module but disable its output. Pick whatever one you like best:

- [https://github.com/yireo/Yireo\_DisableCsp](https://github.com/yireo/Yireo_DisableCsp) - it uses preferences to disable the CSP output
-  - it disables some event observers
-  - it uses plugins to disable the CSP output
- ...

Watch out
---------

[](#watch-out)

- **Do not install this module when you care about PCI DSS compliance!**
- The module is currently declared compatible with specific versions of Magento only, it's hard to predict what will happen in the future, so we'll try to open up compatibility with more future Magento versions when they get released.

Compatibility
-------------

[](#compatibility)

- This module should work with Magento 2.4.4-p9, 2.4.5-p8, 2.4.6-p6, 2.4.7 and 2.4.7-p1
- The module should be compatible with PHP 7.4, 8.1, 8.2 and 8.3

Installation
------------

[](#installation)

You can use composer to install this module:

```
composer require baldwin/magento2-module-csp-shim
```

After which you can then activate it in Magento using:

```
bin/magento setup:upgrade
```

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance86

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 68.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~54 days

Total

13

Last Release

69d ago

PHP version history (2 changes)v1.0.0PHP ~8.2.0 || ~8.3.0

v1.0.1PHP ~7.4.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d62cd17eb7811ff24ce4c4356f63182f29a910c80294eeef17d866a29bdea35?d=identicon)[baldwin](/maintainers/baldwin)

---

Top Contributors

[![hostep](https://avatars.githubusercontent.com/u/85479?v=4)](https://github.com/hostep "hostep (43 commits)")[![baldwinagency-pieter](https://avatars.githubusercontent.com/u/4758823?v=4)](https://github.com/baldwinagency-pieter "baldwinagency-pieter (18 commits)")[![mgeoffray](https://avatars.githubusercontent.com/u/1154299?v=4)](https://github.com/mgeoffray "mgeoffray (2 commits)")

### Embed Badge

![Health badge](/badges/baldwin-magento2-module-csp-shim/health.svg)

```
[![Health](https://phpackages.com/badges/baldwin-magento2-module-csp-shim/health.svg)](https://phpackages.com/packages/baldwin-magento2-module-csp-shim)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
