therobfonz / laravel-security-headers
为 Laravel 响应添加安全头。
3.0.0
2019-10-11 00:00 UTC
Requires
- php: ^8.1
- illuminate/support: ^10.0 || ^11.0
Requires (Dev)
- laravel/pint: ^1.8
- mockery/mockery: ^1.0
- orchestra/testbench: ^8.0 || ^9.0
- phpunit/phpunit: ^9.0 || ^10.0
README
这是一个为您的应用程序添加安全头响应的 Laravel 服务提供者。
安装
您可以通过在项目的 composer.json
中要求 therobfonz/laravel-security-headers
包来使用 Composer 安装 SecurityHeaders 服务提供者。
{ "require": { "therobfonz/laravel-security-headers": "^3.0" } }
在 Laravel 5.6+ 中,包会自动发现。服务提供者和外观定义在 composer.json 中。
配置文件
使用 Artisan 发布配置文件。
php artisan vendor:publish --provider="TheRobFonz\SecurityHeaders\SecurityHeadersServiceProvider"
在生成的 config/security.php
配置文件中更新您的设置。
配置
在 App\Http\Kernel.php
中将中间件添加到 'web' 中间件组。
protected $middlewareGroups = [ 'web' => [ //... \TheRobFonz\SecurityHeaders\Middleware\RespondWithSecurityHeaders::class,
非ces
每个内联脚本标签都需要在开标签中包含 @nonce
blade 指令。
<script @nonce>