zae/strict-transport-security
Composer 安装命令:
composer require zae/strict-transport-security
包简介
Set the HSTS header to enable HTTP Strict Transport Security
关键字:
README 文档
README
Enable HTTP Strict Transport Security using HTTP Middleware
L4 / L5
Middleware is available for both Laravel 4 and 5.
Install
Via Composer
$ composer require zae/strict-transport-security
Usage
Laravel 5
Add the class Zae\StrictTransportSecurity\Middleware\L5\StrictTransportSecurity to the $middlewares array.
#app/Http/Kernel.php protected $middleware = [ 'Illuminate\View\Middleware\ShareErrorsFromSession', 'Zae\StrictTransportSecurity\Middleware\L5\StrictTransportSecurity', ];
It's not strictly required to use the middleware but if you want to use the vendor:publish command add the service provider Zae\StrictTransportSecurity\ServiceProvider\L5HTSTServiceProvider to the providers array in the app config.
#config/app.php return [ 'providers' => [ Illuminate\View\ViewServiceProvider::class, Zae\StrictTransportSecurity\ServiceProvider\L5HTSTServiceProvider::class, ], ];
Publish the config with php artisan vendor:publish. This file will be created at config/hsts.php.
Laravel 4
Add the serviceprovider to the list of service providers: Zae\StrictTransportSecurity\ServiceProvider\L4HTSTServiceProvider
#app/config.php 'providers' => array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', 'Zae\StrictTransportSecurity\ServiceProvider\L4HTSTServiceProvider', ),
Silex Example
require __DIR__ . '/../vendor/autoload.php'; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; $app = new Silex\Application(); $app->get('/', function(Request $request) { return new Response('Hello world!', 200); }); $app = (new Stack\Builder()) ->push('Zae\StrictTransportSecurity\Middleware\L4\StrictTransportSecurity', [new \Zae\StrictTransportSecurity\HSTS(new Illuminate\Config\Repository())]) ->resolve($app) ; $request = Request::createFromGlobals(); $response = $app->handle($request)->send(); $app->terminate($request, $response);
Symfony Example
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Debug\Debug; $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; Debug::enable(); require_once __DIR__.'/../app/AppKernel.php'; $kernel = new AppKernel('dev', true); $kernel->loadClassCache(); $app = (new Stack\Builder()) ->push('Zae\StrictTransportSecurity\Middleware\L4\StrictTransportSecurity', [new \Zae\StrictTransportSecurity\HSTS(new Illuminate\Config\Repository())]) ->resolve($app) ; $kernel = $stack->resolve($kernel); Request::enableHttpMethodParameterOverride(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response);
Testing
$ phpunit
Contributing
Contributions are welcome via pull requests on github.
Credits
License
The MIT License (MIT). Please see License File for more information.
zae/strict-transport-security 适用场景与选型建议
zae/strict-transport-security 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 139.13k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2015 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「middleware」 「laravel」 「ssl」 「Laravel 4」 「StackPHP」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zae/strict-transport-security 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zae/strict-transport-security 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zae/strict-transport-security 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
repository php library
Slim Framework 3 CSRF protection middleware utilities
Cloudflare Middleware For Guzzle
http客户端
Easily add Excepct-CT header to your project
统计信息
- 总下载量: 139.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-27