2017 © Pedro Peláez
 

library csp

Middleware to add the Content-Security-Policy header to the response

image

middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  • Saturday, January 27, 2018
  • by oscarotero
  • Repository
  • 1 Watchers
  • 4 Stars
  • 571 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 27 % Grown

The README.md

middlewares/csp

Latest Version on Packagist ![Software License][ico-license] Testing ![Total Downloads][ico-downloads], (*1)

Middleware to add the Content-Security-Policy header to the response using paragonie/csp-builder library., (*2)

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/csp., (*3)

composer require middlewares/csp

Example

use ParagonIE\CSPBuilder\CSPBuilder;

$csp = CSPBuilder::fromFile('/path/to/source.json');

Dispatcher::run([
    new Middlewares\Csp($csp)
]);

Usage

Set the CSP builder to the constructor. See paragonie/csp-builder for more info. If it's not provided, create a generic one with restrictive directives., (*4)

legacy

To generate legacy CSP headers for old browsers (X-Content-Security-Policy and X-Webkit-CSP). By default is true but you can disabled it:, (*5)

$middleware = (new Middlewares\Csp($csp))->legacy(false);

Helpers

createFromFile

Shortcut to create instances using a json file:, (*6)

Dispatcher::run([
    Middlewares\Csp::createFromFile(__DIR__.'/csp-config.json')
]);

createFromData

Shortcut to create instances using an array with data:, (*7)

Dispatcher::run([
    Middlewares\Csp::createFromData([
        'script-src' => ['self' => true],
        'object-src' => ['self' => true],
        'frame-ancestors' => ['self' => true],
    ])
]);

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details., (*8)

The MIT License (MIT). Please see LICENSE for more information., (*9)

The Versions

27/01 2018

dev-master

9999999-dev https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

27/01 2018

v1.0.1

1.0.1.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

26/01 2018

v1.0.0

1.0.0.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

13/11 2017

v0.6.0

0.6.0.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

21/09 2017

v0.5.0

0.5.0.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

21/09 2017

v0.5.1

0.5.1.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

06/02 2017

v0.4.1

0.4.1.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

05/02 2017

v0.4.0

0.4.0.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

26/12 2016

v0.3.0

0.3.0.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

27/11 2016

v0.2.0

0.2.0.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15

09/10 2016

v0.1.0

0.1.0.0 https://github.com/middlewares/csp

Middleware to add the Content-Security-Policy header to the response

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 security http csp content-security-policy psr-15