Search by

loki-checkout / magento2-csp

loki-extensions

Provides highly recommended CSP, thus PCI DSS 4 compliance

Package info

github.com/LokiCheckout/LokiCheckout_Csp

Type:magento2-module

pkg:composer/loki-checkout/magento2-csp

Fund package maintenance!

yireo

www.paypal.me/yireo

Statistics

Installs: 36

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.16 2026-11-26 00:58 UTC

README

Magento version PHP version License Latest Version

This Magento 2 module is an add-on package for enforcing the CSP Restrictive Mode in the checkout, including the Alpine CSP Build and removing the unsafe-inline and unsafe-eval policies. This is required to be fully compliant with PCI DSS v4.

Note that we develop our core with this module enabled at all times, which ensures that the Loki Checkout is CSP compliant at all times.

Installation

Install this package via composer:

composer require loki-checkout/magento2-csp

Next, enable this module:

bin/magento module:enable LokiCheckout_Csp

Usage notes

Note that this module only covers CSP rules for the LokiCheckout extensions. Your theme still requires work as well to work together with the no-unsafe-inline and no-unsafe-eval policies.

When the Loki Checkout is enabled, this module enforces the CSP (no report-only mode) on the checkout page and removes unsafe-inline and unsafe-eval from script-src. This applies to every theme. Because of this, the following is required:

  • Hyvä: Use the CSP theme Hyva/default-csp (or a child theme of it). The regular Hyva/default theme loads an Alpine.js build that requires unsafe-eval and stops working in the checkout.
  • Luma: This module replaces Alpine.js with the Alpine CSP build in Luma-based themes (themes inheriting from Magento/blank). Knockout UI components are parsed with eval by Knockout and mage/utils/template.js, and break with errors like EvalError: Unable to parse bindings. Therefore, this module removes the Knockout blocks of the Luma page from the checkout (header, customer, catalog.compare.link, compare-link-wrapper, messages, frontend-storage-manager and customer.data.invalidation.rules). The checkout messages are still shown by the Loki messages component. If your theme adds other Knockout UI components to the checkout page, remove them from the checkout layout of your theme.
  • Other themes (Breeze, themes not inheriting from Magento/blank) and MageOS_AlpineLoader: The Alpine CSP build of this module is not loaded there, so make sure that your theme loads an Alpine CSP build itself.

Magento 2.4.6 does not support CSP settings per page. With 2.4.6, this module therefore overrides the global storefront CSP settings, but only for the checkout page.

Current status

Static Tests Unit Tests Integration Tests Playwright DI Compilation