markohs/protectionbanner
Composer 安装命令:
composer require markohs/protectionbanner
包简介
Customizable Laravel Middleware to comply with EU cookie lawls and protect adult websites from child access forcing the client to accept conditions before any cookie or anything is sent.
README 文档
README
Customizable Laravel Middleware to comply with EU Cookie Law (GDPR) and also protect adult websites from child access.
This software goes the hard way to be sure you comply the law:
- All HTTP requests are captured and a full page banner is shown to the user. This page doesn't use cookies at all, no session is mantained.
- Once the user accepts the condition, a cookie is sent, and user is redirected to the original intended page. All future interactions, proceed as usual. Original GET parameters are passed on to the original request.
- It detects crawlers so SEO , opengraph, reddit, twitter... remains unaffected. They are unaffected by this package.
- There is a whitelist mechanism so you can exclude certain URL from your website from this behaviour too.
Take a look at contributing.md to see a to do list.
Installation
Via Composer
$ composer require markohs/protectionbanner
Publish the default config file and default view:
$ php artisan vendor:publish --tag=ProtectionBanner
You can now edit default settings in config/protectionbanner.php and use /resources/views/vendor/protectionbanner/banner.blade.php as a boilerplate for your banner.
Usage
You can use any of the following methods to force the banner:
You can either force HTTPS in a single route in for example routes/web.php:
Route::get('/','StaticPageController@getRoot')->middleware('protectionbanner');
You can also use the automatic MiddlewareGroup register mechanism in config/protectionbanner.php:
'autoregister' => ['web']
Or you can add the Middleware manually as usual in app/Http/Kernel.php in the MiddlewareGroups you require:
... 'web' => [ \App\Http\Middleware\EncryptCookies::class, ... \Markohs\ProtectionBanner\Middleware\ProtectionBannerMiddleware::class, ... \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ..
Cawler and SEO
This Middleware will disable itself if it detects the agent is any crawler or redditbot, so SEO, Google, and reddit/twitter/opengraph fetches remain unaffected.
This is the cause of the jaybizzle/laravel-crawler-detect dependency. I planned to use GEOIP too at some point to be able to disable it on countries where the cookie law might not be important to comply but this is not implemented yet.
Set active environments
This package will only be active in the environments you specify, by default stage, prod and production, update config/protectionbanner.php if necessary:
'enabled_environments' => ['stage', 'prod', 'production'],
URL whitelist mechanism
This package also has a path exclusion mechanism I found useful in my projects. Even if a request is affected by this Middleware, a list of paths is checked, in a "whitelist" spirit, those URLS won't trigger the banner.
You can set this url whitelist in config/protectionbanner.php:
'whitelist' => [ 'example/url', 'example2' ],
Logging
I don't know if it's of any legal value, but it's possible to log the IP of all accepts of conditions. In config/protectionbanner.php:
/* * Channel to log accept info, if necessary * Default: null * example: "accepts" */ 'logchannel' => "accepts"
You will of course need to add that channel to config/logging.php.
Important notes
If you are using Cloudflare or some kind of proxy to serve your website, you need to make sure you configure TrustedProxy correctly or this Middleware might not work correctly.
Make sure you keep the config file /config/trustedproxy.php up to date, or app\Http\Middleware\TrustProxies.php , variable $proxies.
Change log
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email marcos@tyrellcorporation.es instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.
markohs/protectionbanner 适用场景与选型建议
markohs/protectionbanner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「middleware」 「cookies」 「laravel」 「adult」 「ProtectionBanner」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 markohs/protectionbanner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 markohs/protectionbanner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 markohs/protectionbanner 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Use Klaro! Consent Manager in Contao CMS
Slim Framework 3 CSRF protection middleware utilities
Helper class to easily work with cookies.
Cloudflare Middleware For Guzzle
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-05