项目作者: paramonovav

项目描述 :
支持在Laravel 4响应中使用标头实施内容安全策略。
高级语言: PHP
项目地址: git://github.com/paramonovav/laravel4-header-csp.git
创建时间: 2015-08-07T10:44:37Z
项目社区:https://github.com/paramonovav/laravel4-header-csp

开源协议:MIT License

下载


Response header Content Security Policy for Laravel 4

Latest Stable Version Total Downloads Latest Unstable Version License

Provides support for enforcing Content Security Policy and XSS Protection with headers in Laravel 4 responses.

Note: Based on Content Security Policy, Improving Web Security with the Content Security Policy, HTTP headers.

Key Features

  1. Add rules for Content Security Policy (content-security-policy, x-content-security-policy, x-webkit-csp)
  2. Save reports of policy failures to storage/logs/content-security-policy-report folder if needed
  3. Add additional header like: x-xss-protection, x-frame-options, x-content-type-options

Installation

Require this package with composer:

  1. composer require paramonovav/laravel4-header-csp

After updating composer, add the ServiceProvider to the providers array in app/config/app.php

  1. 'Paramonovav\Laravel4HeaderCsp\Laravel4HeaderCspServiceProvider',

You need to publish the config from this package.

  1. php artisan config:publish paramonovav/laravel4-header-csp

Usage

Apply content security policy to routes

The following will apply all default profiles to the login route.

  1. Route::get('login', array('after'=>'response.secure'), function()
  2. {
  3. return 'Hello, on login page !';
  4. }));

The following will apply all default profiles and a specific google profile to the login route.

  1. Route::get('login', array('after'=>'response.secure:google'), function()
  2. {
  3. return 'Hello, on login page !';
  4. }));

You can include any number of specific profiles. The following will apply default, google, flickr, and my_custom profiles to the login route.

  1. Route::get('login', array('after'=>'response.secure:google-flickr-my_custom'), function()
  2. {
  3. return 'Hello, on login page !';
  4. }));