* Security policy management * Minimum password-length policy * Mixed-case, number, and symbol requirements * Password expiry and history settings * MFA requirement policy * Failed-login and lockout settings * Session idle-time policy * Single-session policy * Automatic successful-login recording * Automatic failed-login recording * Automatic logout recording * Authentication history * IP allow and deny rules * IPv4 CIDR support * Administration and login rule scopes * Trusted-device storage and revocation * Security middleware registration * Administration navigation * Security permissions * Module registration and tests
16 lines
559 B
PHP
16 lines
559 B
PHP
<?php
|
|
namespace Modules\Security\Http\Middleware;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Modules\Security\Services\IpRuleService;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
final class EnforceIpRestrictions
|
|
{
|
|
public function __construct(private readonly IpRuleService $rules) {}
|
|
public function handle(Request $request, Closure $next, string $scope='admin'): Response
|
|
{
|
|
abort_if($this->rules->isBlocked((string)$request->ip(),$scope),403,'Access is not permitted from this IP address.');
|
|
return $next($request);
|
|
}
|
|
}
|