PHPackages                             miladev/ip-whitelist - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. miladev/ip-whitelist

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

miladev/ip-whitelist
====================

Laravel middleware to allow only whitelisted IPs

v2.0.0(2w ago)00MITPHPPHP ^7.4|^8.0

Since Jun 8Pushed 2w agoCompare

[ Source](https://github.com/miladev95/ip-whitelist)[ Packagist](https://packagist.org/packages/miladev/ip-whitelist)[ RSS](/packages/miladev-ip-whitelist/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

IP Whitelist, Blacklist Middleware for Laravel
==============================================

[](#ip-whitelist-blacklist-middleware-for-laravel)

Middleware for allowing or blocking requests based on configured IP lists.

Installation
------------

[](#installation)

```
composer require miladev/ip-whitelist
```

Laravel auto-discovers the service provider.

Publish Configuration
---------------------

[](#publish-configuration)

Publish the package config file if you want to change the allowed IPs:

```
php artisan vendor:publish --provider="miladev\\IpWhitelist\\IpWhitelistServiceProvider" --tag=config
```

This creates `config/ip-whitelist.php`.

Usage
-----

[](#usage)

Add the middleware to the routes or route groups you want to protect.

```
use miladev\IpWhitelist\Middleware\IpWhitelistMiddleware;

Route::middleware([IpWhitelistMiddleware::class])->group(function () {
    Route::get('/dashboard', function () {
        return 'Allowed';
    });
});
```

Then list the allowed IPs in `config/ip-whitelist.php`:

```
return [
    'allowed' => [
        '127.0.0.1',
        '192.168.1.100',
    ],
];
```

If the request IP is not in the list, the middleware returns `403` with the message `Your IP address is not allowed.`

To block specific IPs instead, use the blacklist middleware:

```
use miladev\IpWhitelist\Middleware\IpBlacklistMiddleware;

Route::middleware([IpBlacklistMiddleware::class])->group(function () {
    Route::get('/admin', function () {
        return 'Protected';
    });
});
```

Then list blocked IPs in `config/ip-whitelist.php`:

```
return [
    'blocked' => [
        '10.0.0.1',
    ],
];
```

If the request IP is in the blocked list, the middleware returns `403` with the message `Your IP address is blocked.`

Notes
-----

[](#notes)

- The middleware uses `Request::ip()`, so trusted proxy configuration affects the detected client IP.
- Keep the allow list tight and review it whenever your infrastructure changes.

Requirements
------------

[](#requirements)

- PHP `^7.4 || ^8.0`
- Laravel / `illuminate/support` `^8.0 || ^9.0 || ^10.0`

###  Health Score

38

↑

LowBetter than 83% of packages

Maintenance96

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~372 days

Total

2

Last Release

19d ago

Major Versions

v1.0.0 → v2.0.02026-06-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35612406?v=4)[Milad](/maintainers/miladev95)[@miladev95](https://github.com/miladev95)

---

Top Contributors

[![miladev95](https://avatars.githubusercontent.com/u/35612406?v=4)](https://github.com/miladev95 "miladev95 (5 commits)")

### Embed Badge

![Health badge](/badges/miladev-ip-whitelist/health.svg)

```
[![Health](https://phpackages.com/badges/miladev-ip-whitelist/health.svg)](https://phpackages.com/packages/miladev-ip-whitelist)
```

###  Alternatives

[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5752.3M18](/packages/directorytree-ldaprecord-laravel)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[althinect/filament-spatie-roles-permissions

3481.1M10](/packages/althinect-filament-spatie-roles-permissions)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6804.7k6](/packages/hasinhayder-tyro)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1563.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
