├── ip-blocker.jpg
├── src
├── IPBlocker.php
├── Middlewares
│ └── IPBlocking.php
├── Models
│ └── IPBlocker.php
├── Migrations
│ └── 2020_07_22_180122_create_ipblockers_table.php
└── IPBlockerServicesProvider.php
├── tests
└── TestCase.php
├── composer.json
├── phpunit.xml
└── README.md
/ip-blocker.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Mahmoud-Italy/Larasecure-ipblocker/HEAD/ip-blocker.jpg
--------------------------------------------------------------------------------
/src/IPBlocker.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Middlewares/IPBlocking.php:
--------------------------------------------------------------------------------
1 | \Request::ip(), 'status' => true])->count()) {
25 | $obj = true;
26 | }
27 | return $obj;
28 | }
29 | }
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "larasecure/ip-blocker",
3 | "description": "Restrict access to the web by preventing IP Addresses",
4 | "type": "library",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "Mahmoud.Ahmed",
9 | "email": "mahmoud.italy@outlook.com"
10 | }
11 | ],
12 | "minimum-stability": "dev",
13 | "prefer-stable": true,
14 | "require": {
15 | "php": "^7.2"
16 | },
17 | "extra": {
18 | "laravel": {
19 | "providers": [
20 | "Larasecure\\IPBlocker\\IPBlockerServiceProvider"
21 | ]
22 | }
23 | },
24 | "autoload": {
25 | "psr-4": {
26 | "Larasecure\\IPBlocker\\": "src/"
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | 
7 |
8 | A Laravel Package to increase the security of your websites by preventing access for users having blocked IP Addresses.
9 |
10 | However, you can add IP Addresses as many as you want into table called ipblockers which you want to disallow access to your site from spam etc.
11 |
12 | # Installation
13 |
composer require larasecure/ip-blocker14 | 15 | # Then publish the config 16 |
php artisan vendor:publish --tag=ipblocker17 |
php artisan migrate18 | 19 | 20 | # Usage 21 | Add this middleware in Kernel.php $routeMiddleware to restrict IP Addresses 22 | 23 |
'IPBlocking' => \Larasecure\IPBlocker\Middlewares\IPBlocking::class24 | 25 | Add IPBlocking middleware to route group for which you want to restrict access. 26 |
27 | Route::group(['middleware' => 'IPBlocking'], function(){
28 | // you routes..
29 | });
30 |
31 | or you can injected in RouteServiceProvider.php
32 |
33 | protected function mapApiRoutes()
34 | {
35 | Route::prefix('api')
36 | ->middleware(['api', 'IPBlocking'])
37 | ->namespace($this->namespace)
38 | ->group(base_path('routes/api.php'));
39 | }
40 |
41 |
42 | or just add middleware to single route
43 |
44 | Route::get('/', function () {
45 | //
46 | })->middleware('IPBlocking');
47 |
48 |