adaptivemedia/laravel-site-lock
Composer 安装命令:
composer require adaptivemedia/laravel-site-lock
包简介
Lock access to a site
README 文档
README
Sometimes you don't want anybody to access your site. Use cases include:
- Site is under development
- Site is on a staging/testing server
- Site is an internal tool
This package adds a global web middleware that protects all routes until it's unlocked.
Installation
You can install the package via composer:
composer require adaptivemedia/laravel-site-lock
You MUST publish the config file with:
php artisan vendor:publish --provider="Adaptivemedia\SiteLock\SiteLockServiceProvider" --tag="config"
This is the content of the config file:
<?php return [ /* * This is the master switch to enable site lock. */ 'enabled' => env('SITE_LOCK_ENABLED', true), /* * Environments that the site lock should be applied to. */ 'environments' => ['staging', 'development'], /* * The following IP's will automatically gain access to the * app without having to visit the `access-url` url. */ 'allowed-ips' => [], /* * List of urls that are whitelisted. * * Examples: * /a-webhook-url * a-webhook-url * api/a-webhook-url * api/a-webhook-* */ 'whitelisted-urls' => [], /* * The url that will unlock the site. */ 'access-url' => '/change-this-url-to-your-own', /* * After having gained access, visitors will be redirected to this url. */ 'redirect-url' => '/', /* * The session key that holds the site lock. */ 'session-key' => 'site-lock', /* * Error message displayed for users without access. */ 'error-message' => 'Access denied', /* * HTTP response for users without access. */ 'error-http-response' => 401, ];
Usage
Add the middleware to the $middlewareGroups array in App\Http\Kernel.php:
protected $middlewareGroups = [
'web' => [
...
\Adaptivemedia\SiteLock\SiteLock::class,
...
]
]
When added, all routes are locked if the request is on a matching environment. You can also assign this middleware to specific routes
by adding an alias to the $routeMiddleware variable and then attaching that alias to a route.
Gain access via url
You can now gain access your site by visiting the configured url.
Gain access via IP
You can add allowed IP addresses in the allowed-ips config variable. You can either use a comma separated string:
'allowed-ips' => '127.0.0.1,192.168.0.1'
or use an array:
'allowed-ips' => [
'127.0.0.1',
'192.168.0.1'
]
To change allowed IPs without changing code, you can use your own env-variable, eg. SITE_LOCK_ALLOWED_IPS:
'allowed-ips' => env('SITE_LOCK_ALLOWED_IPS')
And set them in your .env:
SITE_LOCK_ALLOWED_IPS="127.0.0.1, 192.168.0.1"
Whitelist urls
You can whitelist individual urls so they are excluded from the middleware. A common use case could be a hook url that a third party service is calling in your app.
'whitelisted-urls' => [
'/webhook-callback-url',
],
Disable site lock
If you don't want to enable site lock, just set the env variable SITE_LOCK_ENABLED to false.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@adaptivemedia.se instead of using the issue tracker.
Credits
Support us
Adaptivemedia is a web agency based in Stockholm, Sweden. Visit our website.
License
The MIT License (MIT). Please see License File for more information.
adaptivemedia/laravel-site-lock 适用场景与选型建议
adaptivemedia/laravel-site-lock 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.99k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「adaptivemedia」 「laravel-site-lock」 「demo mode」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adaptivemedia/laravel-site-lock 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adaptivemedia/laravel-site-lock 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adaptivemedia/laravel-site-lock 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Handles and formats swedish personnummer
The Aura Framework_Demo package provides sample 'Hello World' web and CLI demos for the Aura framework.
allows you to review sunnysideup/ecommerce
Demo project for the Cora development framework. Cora is a framework for easily building MVC style web applications.
A Framework Demo Plugin
Demonstrates all formfields in Voyager II
统计信息
- 总下载量: 23.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-16