定制 voyager-inc/simple-block-blacklist-and-whitelist-ip 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

voyager-inc/simple-block-blacklist-and-whitelist-ip

Composer 安装命令:

composer require voyager-inc/simple-block-blacklist-and-whitelist-ip

包简介

Simple block ip depend on blacklist and whitelist ip

README 文档

README

PHP v8.2

Laravel v11.x

Installation

composer require voyager-inc/simple-block-blacklist-and-whitelist-ip
  • Publish provider
php artisan vendor:publish --provider="VoyagerInc\SimpleBlockBlacklistAndWhiteListIp\ServiceProvider"

Now you will see two migration files create_simple_blacklist_ips_table.php and create_simple_whitelist_ips_table.php in database/migrations folder

  • Run migration
php artisan migrate

Usage

  • We have two new middleware with the aliases ip-filter-whitelist and ip-filter-blacklist
  • The ip-filter-whitelist middleware allows access only from whitelisted IPs.
  • The ip-filter-blacklist middleware always prevents access from blacklisted IPs.
  • We can update whitelist and blacklist in config simple_block_blacklist_and_whitelist_ip.php file
<?php

return [
    'block_ip_enable' => true,

    'block_by' => 'config', // or database

    'whitelist_ip' => [
        //
    ],

    'blacklist_ip' => [
        //
    ],
];
  • Example
Route::get('/test', function () {
    return 'Whitelist route';
})->middleware(['ip-filter-whitelist']); // middleware(['ip-filter-blacklist']

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-08