Download the PHP package bnomei/kirby3-security-headers without Composer

On this page you can find all versions of the php package bnomei/kirby3-security-headers. 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 kirby3-security-headers

Kirby Content Security Policy Header

Kirby 5 PHP 8.2 Release Downloads Coverage Maintainability Discord Buymecoffee

Kirby Plugin for easier Content Security Policy (CSP) Headers setup.

Installation

Default CSP Headers

The following headers will be applied by default, you do not need to set them explicitly. They provide a good starting point for most websites and ensure a sane level of security.

[!TIP] See \Bnomei\SecurityHeaders::HEADERS_DEFAULT for more details.

Zero Configuration? Almost.

Installing the plugin is enough to protect your website. A route:before-hook takes care of sending the CSP headers automatically. But you will most likely need to customize the CSP headers when using third-party services like

[!TIP] The plugin will automatically disable itself on local setups to not get in your way while developing. To test the CSP headers locally, you can use the 'bnomei.securityheaders.enabled' => true, option to enforce sending the headers.

Customizing CSP Headers & Nonces

You can customize the CSP headers by providing a custom Loader and/or Setter via the Kirby config.

Loader

The Loader is used to initially create the CSP-Builder object with a given set of mostly static data. You can provide a path to a file, return an array or null to create blank CSP-Builder object.

[!TIP] See \Bnomei\SecurityHeaders::LOADER_DEFAULT for more details.

[!WARNING] Consider using a custom loader ONLY if you find yourself adding a lot of configurations in the Setter. The default loader is already quite extensive and should cover most use-cases.

Setter

The Setter is applied after the Loader. Use it to add dynamic stuff like rules for external services, hashes and nonces.

/site/config/config.php

[!TIP] You can define nonces in the Setter-option and later retrieved using $page->nonce(...) or $page->nonceAttr(...). But the plugin also provides a single nonce for frontend use out of the box.

Nonces

For convenience the plugin also provides you with a single frontend nonce to use as attribute in <link>, <style> and <script> elements. You can retrieve the nonce with site()->nonce().

[!NOTE] This plugin automatically registers the nonce that Kirby creates for its panel (in case that ever might be needed).

Disabling the plugin

The CSP headers will be sent before Kirby renders HTML using a route:before hook but the plugin will be automatically disabled if one the following conditions apply:

[!WARNING] By default, CSP headers are never sent for any Kirby Panel, API and Media routes.

Settings

bnomei.securityheaders. Default Description
enabled null/true/false will set headers
seed callback returns a unique seed for frontend nonces on every request
headers callback array of sensible default values
loader callback returning filepath or array
setter callback instance which allows customizing the CSPBuilder

Dependencies

Disclaimer

This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.

License

MIT

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.


All versions of kirby3-security-headers with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
getkirby/composer-installer Version ^1.2
paragonie/csp-builder Version ^3.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 bnomei/kirby3-security-headers contains the following files

Loading the files please wait ....