Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arubacao/aws-ip-range-middleware
Laravel Middleware for Amazon Web Services (AWS) IP Address Range Validation
https://github.com/arubacao/aws-ip-range-middleware
aws ip ip-ranges laravel middleware
Last synced: 11 days ago
JSON representation
Laravel Middleware for Amazon Web Services (AWS) IP Address Range Validation
- Host: GitHub
- URL: https://github.com/arubacao/aws-ip-range-middleware
- Owner: arubacao
- License: mit
- Created: 2018-02-14T10:01:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-03T00:07:50.000Z (over 3 years ago)
- Last Synced: 2024-01-23T16:05:54.777Z (10 months ago)
- Topics: aws, ip, ip-ranges, laravel, middleware
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Middleware for Amazon Web Services (AWS) IP Address Range Validation
[![Latest Version on Packagist](https://img.shields.io/packagist/v/arubacao/aws-ip-range-middleware.svg?style=flat-square)](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://img.shields.io/codecov/c/github/arubacao/aws-ip-range-middleware.svg?style=flat-square)](https://codecov.io/gh/arubacao/aws-ip-range-middleware)
[![Total Downloads](https://img.shields.io/packagist/dt/arubacao/aws-ip-range-middleware.svg?style=flat-square)](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
- 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_ --> only fetched once per day
- Retry with exponential back-off on network issues while fetching the _ip address range_ from AWS#### Notes
- `arubacao/aws-ip-range-middleware` is functional and fully tested for Laravel `5.0` - `7.*` and PHP `7.0` - `7.3`.
## Installation
Install this package via composer:```bash
composer require arubacao/aws-ip-range-middleware
```#### Registering Middleware
First assign the _aws-ip-range-middleware_ a key in your `app/Http/Kernel.php` file to the `$routeMiddleware` property.
```PHP
// 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
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:
```PHP
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_```PHP
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
- Enable/Disable caching
- Choose cache storage
- Command to fetch ip address range and store locally## Testing
``` bash
composer test
```## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Credits
- [Christopher Lass](https://github.com/arubacao)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.