hayrican/ipchecker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hayrican/ipchecker

Composer 安装命令:

composer require hayrican/ipchecker

包简介

Laravel package for providing restricted access by IP Address to your application

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version Scrutinizer Code Quality Codacy Badge Build Status Code Intelligence Status License

This package provides restricted access via IP Address to your application.

Installation

To get started, you should add the hayrican/ipchecker Composer dependency to your project:

composer require hayrican/ipchecker

Service Provider (Laravel Older 5.5)

If you are using later version of Laravel 5.5, you can skip this step.

Register provider on your config/app.php file.

'providers' => [
    ...,
    HayriCan\IpChecker\IpCheckerServiceProvider::class,
]

Configuration

You should publish vendor for configuration file.

$ php artisan vendor:publish --tag="ipchecker"
Driver

The config file is called ipchecker.php. Currently supported drivers are db and file

Default driver is file and ipchecker will use file to record ip addresses. But if you want to use Database for records, migrate table by using

php artisan migrate

You have to change driver to db before migrate. Otherwise it will not migrate the table.

Route Group Middleware
'api_middleware'=>'api',
'web_middleware'=>'web',

If your routes has different middleware then these default values you can change them in here. These route middleware need for filtering response of denial access.

Localization

When you call php artisan vendor:publish --tag="ipchecker" command, it will also publish lang file to your resources/lang directory. You can change all fields as you desire.

Package Usage

1.Add Middleware

Add middleware named ipchecker to the route or controller you want to log data

// in app.php or web.php

Route::group(['middleware' => ['ipchecker']], function () {
    Route::get('test',function (){
        dd('Test API');
    });
});

When try to access this route it will check your IP Address. If you ip address is not on the list you will get response

{
    "success": false,
    "code": 250,
    "message": "Your IP Address not in the list."
}

Otherwise you will access to the route.

2.Add IP Address

Up to default config dashboard can be accessible via yourdomain.com/iplists but it is configurable from config file ipchecker.php

{
"settings"=>[
    "auth"       => false,
    "admin_id"=>[],
    "route_prefix"=> "",
    ],
}

If you want to guard this page just change "auth" to true and it require "auth" middleware.

When you enabled auth you could add admin users id to "admin_id" array. If leave "admin_id" array empty, all users can has access to IP Checker dashboard

{
"settings"=>[
   "auth"=> true,
   "admin_id"=>[2,5],
   "route_prefix"=> "",
   ],
}

Also you can change the route prefix of this dashboard. If you change "route_prefix" to "foo" your dashboard will be accessible via yourdomain.com/foo/iplists.

Screencast1

You can add IP Address in here.

Author

Hayri Can BARÇIN
Email: Contact Me

License

This project is licensed under the MIT License - see the License File for details

hayrican/ipchecker 适用场景与选型建议

hayrican/ipchecker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 902 次下载、GitHub Stars 达 27, 最近一次更新时间为 2019 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「access」 「helper」 「laravel」 「ip address」 「PHP7」 「restricted」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hayrican/ipchecker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hayrican/ipchecker 我们能提供哪些服务?
定制开发 / 二次开发

基于 hayrican/ipchecker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 902
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 27
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-28