Initial commit: CABM-IT (ItGlue-style MSP documentation platform)
Laravel 13 + Livewire/Volt app for managing client organizations, documents, passwords, flexible assets, virtual machines, contacts, domains, todos, shortcuts, and role-based user administration.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\IpUtils;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CheckOrganizationIpAccess
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Closure(Request): (Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$organization = $request->route('organization');
|
||||
|
||||
if (! $organization || empty($organization->allowed_ip_ranges)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
if (IpUtils::checkIp($request->ip(), $organization->allowed_ip_ranges)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
abort(403, 'Your IP address is not permitted to access this organization.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user