PHPackages                             arubacao/aws-ip-range-middleware - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. arubacao/aws-ip-range-middleware

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arubacao/aws-ip-range-middleware
================================

Laravel Middleware for Amazon Web Services (AWS) IP Address Range

1.0.2(5y ago)172.3k[1 issues](https://github.com/arubacao/aws-ip-range-middleware/issues)MITPHPPHP ^7.0|^8.0CI failing

Since Feb 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/arubacao/aws-ip-range-middleware)[ Packagist](https://packagist.org/packages/arubacao/aws-ip-range-middleware)[ Docs](https://github.com/arubacao/aws-ip-range-middleware)[ RSS](/packages/arubacao-aws-ip-range-middleware/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Laravel Middleware for Amazon Web Services (AWS) IP Address Range Validation
============================================================================

[](#laravel-middleware-for-amazon-web-services-aws-ip-address-range-validation)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a2ac859e5f68742cdd77042e8513fad782e0e6fbbd628046429e698ffbcece2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617275626163616f2f6177732d69702d72616e67652d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arubacao/aws-ip-range-middleware)[![Run Tests](https://github.com/arubacao/aws-ip-range-middleware/workflows/Run%20Tests/badge.svg)](https://github.com/arubacao/aws-ip-range-middleware/actions?query=workflow%3A%22Run+Tests%22)[![Codecov](https://camo.githubusercontent.com/dbaba7ffc753514b74f9927ccbcb2681ed73fa9ac905d7771f6737da57664ee3/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f617275626163616f2f6177732d69702d72616e67652d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/arubacao/aws-ip-range-middleware)[![Total Downloads](https://camo.githubusercontent.com/7050f4447790496dfb68ce080ffa45fb966b32fd933fcb5a46ea4c4e7e1b556b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617275626163616f2f6177732d69702d72616e67652d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arubacao/aws-ip-range-middleware)

This package allows for **validation** of incoming **requests** against the official [Amazon Web Services (AWS) IP Address Range](https://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html).
Use this to determine if an incoming request actually comes from the AWS infrastructure e.g. for [Simple Notification Service (SNS)](https://docs.aws.amazon.com/sns/latest/dg/welcome.html) payloads.

Features
--------

[](#features)

- Passes incoming HTTP requests from AWS, rejects everything else
- AWS *ip address range* is fetched on demand and therefore always up-to-date
- Caching of *ip address range* --&gt; only fetched once per day
- Retry with exponential back-off on network issues while fetching the *ip address range* from AWS

#### Notes

[](#notes)

- `arubacao/aws-ip-range-middleware` is functional and fully tested for Laravel `5.0` - `7.*` and PHP `7.0` - `7.3`.

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

[](#installation)

Install this package via composer:

```
composer require arubacao/aws-ip-range-middleware
```

#### Registering Middleware

[](#registering-middleware)

First assign the *aws-ip-range-middleware* a key in your `app/Http/Kernel.php` file to the `$routeMiddleware` property.

```
// Within App\Http\Kernel Class...

protected $routeMiddleware = [
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    // .
    // .
    // .
    'aws-ip-range' => \Arubacao\AwsIpRange\AwsIpRangeMiddleware::class,
];
```

Usage
-----

[](#usage)

Once the *aws-ip-range-middleware* has been defined in the HTTP kernel, you may use the middleware method to assign *aws-ip-range-middleware* to a route:

```
Route::post('api/sns', function () {
    //
})->middleware('aws-ip-range');

// Older Laravel Versions:
Route::post('api/sns', ['middleware' => 'aws-ip-range', function () {
    //
}]);
```

When assigning middleware, you may also pass the fully qualified class name:
*Note: In this case you do not need to register the aws-ip-range-middleware in the HTTP kernel*

```
use Arubacao\AwsIpRange\AwsIpRangeMiddleware;

Route::post('api/sns', function () {
    //
})->middleware(AwsIpRangeMiddleware::class);

// Older Laravel Versions:
Route::post('api/sns', ['middleware' => AwsIpRangeMiddleware::class, function () {
    //
}]);
```

Todo's
------

[](#todos)

- Enable/Disable caching
- Choose cache storage
- Command to fetch ip address range and store locally

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Christopher Lass](https://github.com/arubacao)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity70

Established project with proven stability

 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 ~586 days

Total

3

Last Release

1838d ago

PHP version history (2 changes)1.0.0PHP ^7.0

1.0.2PHP ^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf7b2190f2ba29dfa66717532be353fcf9d5bd16fe49a5dbe5853dd9f1af44a9?d=identicon)[arubacao](/maintainers/arubacao)

---

Top Contributors

[![arubacao](https://avatars.githubusercontent.com/u/7462542?v=4)](https://github.com/arubacao "arubacao (25 commits)")

---

Tags

awsipip-rangeslaravelmiddlewaremiddlewarelaravelawsip range

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arubacao-aws-ip-range-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/arubacao-aws-ip-range-middleware/health.svg)](https://phpackages.com/packages/arubacao-aws-ip-range-middleware)
```

###  Alternatives

[laravolt/avatar

Turn name, email, and any other string into initial-based avatar or gravatar.

2.0k5.4M31](/packages/laravolt-avatar)[timacdonald/has-parameters

A trait that allows you to pass arguments to Laravel middleware in a more PHP'ish way.

228271.7k2](/packages/timacdonald-has-parameters)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[yemenifree/laravel-arabic-numbers-middleware

auto transforms arabic/eastern to eastern/arabic numbers for i.e ١٢٣٤٥٦٧٨ to 12345678

18135.4k](/packages/yemenifree-laravel-arabic-numbers-middleware)[dumpk/elastcoder

AWS Elastic Transcoder Service Integration

2819.7k](/packages/dumpk-elastcoder)

PHPackages © 2026

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