teraone / laravel-cloudflare-zero-trust-middleware
使用 Cloudflare Zero Trust 保护特定路由的中间件
1.2
2024-09-21 19:13 UTC
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.5
- illuminate/contracts: ^9.0|^10.0|^11.0
- spatie/laravel-package-tools: ^1.16
- web-token/jwt-library: ^3.4
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2024-09-21 19:19:49 UTC
README
安装
您可以通过 composer 安装此包
composer require teraone/laravel-cloudflare-zero-trust-middleware
配置
使用以下命令发布配置文件
php artisan vendor:publish --tag="cloudflare-zero-trust-middleware-config"
这是发布配置文件的内容
return [ /* |-------------------------------------------------------------------------- | Cloudflare Team Name |-------------------------------------------------------------------------- | | Here you should define the name of your Cloudflare Team Account. | Not sure? Open https://one.dash.cloudflare.com/ | It will be the name on which you click. | */ 'cloudflare_team_name' => env('CLOUDFLARE_TEAM_NAME'), /* |-------------------------------------------------------------------------- | Cloudflare Zero Trust / Application Audience Tag |-------------------------------------------------------------------------- | | Please enter the Application Audience Tag which you want to protect. | Open the Zero Trust Dashboard at https://one.dash.cloudflare.com/: | Access > Applications: Select "Configure" for your application. | On the overview tab, copy the "Application Audience (AUD) Tag". | */ 'cloudflare_zero_trust_application_audience_tag' => env('CLOUDFLARE_ZERO_TRUST_APPLICATION_AUDIENCE_TAG'), /* |-------------------------------------------------------------------------- | Use certificate cache |-------------------------------------------------------------------------- | | Should it cache the cloudflare certificates. | */ 'cache' => true, /* |-------------------------------------------------------------------------- | Certificate cache TTL |-------------------------------------------------------------------------- | | How long should we cache your public cloudflare certificates? In seconds. | The certificate cache will be flushed when a new certificate is detected. | */ 'cache_ttl' => 60 * 60 * 24, /* |-------------------------------------------------------------------------- | Disable the middleware on these environments |-------------------------------------------------------------------------- | | Most likely you do not have cloudflare available during development. | Use this setting to bypass the middleware for specific environments. | */ 'disabled_environments' => [ 'local', ], ];
使用方法
将中间件添加到您想要保护的路由中。
// with shorthand alias Route::get('/protected', function(){ return 'Protected by Cloudflare Zero trust ✅';}) ->middleware('cloudflare-zero-trust'); // OR: Use Class directly Route::get('/also-secure', function(){ return 'Also protected by Cloudflare Zero trust ✅';}) ->middleware(\Teraone\ZeroTrustMiddleware\ZeroTrustMiddleware\ZeroTrustMiddleware::class);
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全漏洞
请查看 我们的安全策略 了解如何报告安全漏洞。
致谢
许可
MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。
支持 Spatie
我们投入了大量资源来创建 一流的开放源代码包。您可以通过 购买我们的付费产品之一 来支持我们。
我们非常感谢您从家乡寄给我们明信片,提及您正在使用我们的哪个包。您可以在 我们的联系页面 上找到我们的地址。我们将所有收到的明信片发布在我们的 虚拟明信片墙上。