2017 © Pedro Peláez
 

library aws-ip-range-middleware

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

image

arubacao/aws-ip-range-middleware

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

  • Thursday, February 15, 2018
  • by arubacao
  • Repository
  • 1 Watchers
  • 13 Stars
  • 207 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 46 % Grown

The README.md

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

Latest Version on Packagist Run Tests Codecov Total Downloads, (*1)

This package allows for validation of incoming requests against the official Amazon Web Services (AWS) IP Address Range.
Use this to determine if an incoming request actually comes from the AWS infrastructure e.g. for Simple Notification Service (SNS) payloads., (*2)

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:, (*3)

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., (*4)

// 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:, (*5)

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, (*6)

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, (*7)

Contributing

Please see CONTRIBUTING for details., (*8)

Credits

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

15/02 2018

dev-master

9999999-dev https://github.com/arubacao/aws-ip-range-middleware

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

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel middleware aws ip-range

15/02 2018

1.0.0

1.0.0.0 https://github.com/arubacao/aws-ip-range-middleware

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

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel middleware aws ip-range