2017 © Pedro Peláez
 

yii2-extension yii2-cspreport

Yii2 Module for Content Security Policy Report

image

assayer-pro/yii2-cspreport

Yii2 Module for Content Security Policy Report

  • Friday, June 1, 2018
  • by assayer-pro
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,357 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

yii2-cspreport

yii2 Module for Content Security Policy Report, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

  • Either run
php composer.phar require --prefer-dist "assayer-pro/yii2-cspreport" "*"

or add, (*3)

"assayer-pro/yii2-cspreport" : "*"

to the require section of your application's composer.json file., (*4)

Usage

  • Add a new module in modules section of your application's configuration file, for example:
    'modules' => [
        'csp-report' => [
            'class' => 'assayerpro\cspreport\Module',
            'message' => [
                'from' => 'admin@example.com',
                'to' => 'developer@example.com',
                'subject' => 'Content Security Policy Report',
            ],
        ],
    ],
  • Add a new rule for urlManager of your application's configuration file, for example:
    'components' => [
    ...
        'urlManager' => [
            'rules' => [
                'csp-report' => 'csp-report/report/index',
            ],
        ],
    ...
    ],
  • Add application/csp-report parser:
    'components' => [
    ...
        'request' => [
            'parsers' => [
                'application/csp-report' => 'yii\web\JsonParser',
            ],
        ],
    ...
    ],
  • Apache Content-Security-Policy Header

Add the following to your httpd.conf in your VirtualHost or in an .htaccess file:, (*5)

Header set Content-Security-Policy-Report-Only "default-src https:; script-src https: 'unsafe-eval' 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:; report-uri /csp-report;"
  • Nginx Content-Security-Policy Header

In your server {} block add:, (*6)

   add_header Content-Security-Policy-Report-Only "default-src https:; script-src https: 'unsafe-eval' 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:; report-uri /csp-report";

You can also append always to the end to ensure that nginx sends the header reguardless of response code., (*7)

The Versions

01/06 2018

dev-master

9999999-dev https://github.com/assayer-pro/yii-cspreport

Yii2 Module for Content Security Policy Report

  Sources   Download

MIT

The Requires

 

01/06 2018

dev-develop

dev-develop https://github.com/assayer-pro/yii-cspreport

Yii2 Module for Content Security Policy Report

  Sources   Download

MIT

The Requires

 

20/02 2016

1.0.1

1.0.1.0 https://github.com/assayer-pro/yii-cspreport

Yii2 Module for Content Security Policy Report

  Sources   Download

MIT

The Requires

 

20/02 2016

1.0.0

1.0.0.0 https://github.com/assayer-pro/yii-cspreport

Yii2 Module for Content Security Policy Report

  Sources   Download

MIT

The Requires