smorken / ip-auth
IP Authorization - not truly secure!
v10.4.0
2024-08-13 18:10 UTC
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0
- smorken/auth: ^1.0
- smorken/model: ^10.0
- smorken/pin-auth: ^1.0
- smorken/sanitizer: ^10.0
- smorken/support: ^10.0
Requires (Dev)
- larastan/larastan: ^v2.9.8
- mockery/mockery: ^1.0
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0|^11.0
- smorken/docker: *
- smorken/roles: ^10.0
- spatie/laravel-ignition: ^2.0
README
Laravel IP Authorization
Contains some helpers for the basic IP Authorization. Note that IP addresses can be spoofed to some extent (mainly incorrect use of a proxy).
Service provider should be auto loaded but if not:
Add
\Smorken\IpAuth\ServiceProvider::class
to theconfig/app.php
service providersIf needed, publish the config and view files
php artisan vendor:publish --provider="Smorken\IpAuth\ServiceProvider" --tag=views
php artisan vendor:publish --provider="Smorken\IpAuth\ServiceProvider" --tag=config
Add the middleware to your
App\Http\Kernel.php
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
...
'ip-active' => \Smorken\IpAuth\Http\Middleware\IpActive::class,
'user-active' => \Smorken\IpAuth\Http\Middleware\UserActive::class,
...
];
- Add the middleware key to your routes that need it
Route:middleware(['ip-active', 'user-active'])
->group(function () {
Route::get('/', 'HomeController@index');
Route::get('/customers', 'HomeController@customers');
Route::post('/cart/{customer_id}', 'CartController@doCart');
});
- Add to
config/menus.php
...
'role-manage' => [
[
'name' => 'Authorize',
'action' => [\Smorken\IpAuth\Http\Controllers\AuthorizeController::class, 'index'],
'children' => [],
],
...