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

On this page you can find all versions of the php package blackbird/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

Blackbird CSP Manager

Latest Stable Version

This module allows managing Content Security Policy (CSP) rules directly from the Magento command line (CLI). The rules are stored in the app/etc/env.php file, which allows for environment-specific management without going through the database or the backoffice.

Important: The rules managed by this module are added to (not replacing) the existing Magento CSP rules defined in csp_whitelist.xml files.

Key functionality includes:

Security

This module is designed to be safe from SQL injections. All configuration is handled through the Magento CLI and stored directly in the app/etc/env.php file. Since no database storage is used for the CSP rules themselves, it eliminates the risk of SQL-based attacks for CSP management.

Additionally, this approach provides several security benefits:

The source code is available at the GitHub repository.


Setup

Get the Package

Zip Package:

Unzip the package into app/code/Blackbird/CSPManager, from the root of your Magento instance.

Composer Package:

Install the Module

Go to your Magento root directory, then run the following Magento commands:

If you are in production mode, do not forget to recompile and redeploy the static resources, or to use the --keep-generated option.


Features

Usage via CLI

Add value(s) to a directive

Adds one or more values to an existing or new directive. Note that these values are added additionally to any values already defined in Magento's csp_whitelist.xml files.

Example:

If the directive does not exist, it is created in env.php. If it exists, the new values are added to existing values (no duplicates).

Overwrite/Set a complete directive

Sets the values for a directive in env.php. Note that these values are still additive to those defined in csp_whitelist.xml files; this command only overwrites other values managed by this module in env.php.

Example:

This command replaces the current value of the directive with the provided one.

Unset a complete directive

Example:

This command is the inverse of csp:rule:set to completely remove a directive.

List rules

Remove value(s) or a directive

Example to remove specific value(s):

Example to remove a complete directive:

Note: The add, set, remove, and unset commands validate that the directive passed as an argument is valid according to the CSP specification (list from MDN).

Configure the header splitter

Set the splitter configuration in env.php. Both options are optional — only the option you pass is changed; the other keeps its current value. Enabled: true by default Max header size: 8192 by default, which is a Varnish response header size's default value

Show the current splitter configuration:

Migrate legacy rules (existing installations)

Earlier versions stored the CSP rules flat under the csp key. Run this once to move them under csp/rules:

The command is idempotent: running it again when there is nothing to migrate changes nothing.

Important: After making any changes to CSP rules, you should clean the full_page cache to reflect the changes on the frontend:

Technical Configuration

The rules are stored in app/etc/env.php under csp/rules, and the header-splitter configuration under csp/splitter_config:

The module uses a custom collector Blackbird\CSPManager\Model\Collector\EnvPolicyCollector injected into Magento\Csp\Model\CompositePolicyCollector.

A plugin on Magento\Csp\Model\CspRenderer ensures that CSP headers are split if necessary to avoid header size errors on some servers (default 8KB limit).

When a header is split, the module uses the principle that multiple CSP headers are combined by the browser as an intersection (a resource must be allowed by all headers).

To ensure that the split headers do not become more restrictive than the original single header, the module ensures that:

The "opened" values used are:

Example: If Header 1 contains img-src site1.com, and Header 2 contains img-src site2.com, the browser would normally block both (since site1.com is not in Header 2 and site2.com is not in Header 1). By "opening" img-src in Header 1 to include * data: blob: and doing the same in Header 2, the combined effect correctly allows both site1.com and site2.com.


Credits

The CSP header splitting logic is based on the work by basecom in the magento2-csp-split-header module.


Support

For further information, contact us:


Authors


License

This project is licensed under the MIT License - see the LICENSE file for details.


That's all folks!


All versions of module-csp-manager with dependencies

PHP Build Version
Package Version
Requires magento/framework Version *
magento/module-csp Version *
php Version ^8.2
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 blackbird/module-csp-manager contains the following files

Loading the files please wait ...