Audit module: audit log and address bans
This commit is contained in:
1 parent
b75403e5ea
commit
d2ea1bacac
41 files changed
+2137
-5
No files matched your search
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace IriksIT\Manager\Modules\Audit;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Keeps an address with a ban "for the whole site" away from everything. Only added when
|
||||
* `manager.audit.whole_site_bans` is on. It runs for every request, so the question is answered
|
||||
* from the cache (IpBans::wholeSite) and costs a visitor nothing.
|
||||
*/
|
||||
class RefuseBannedFromTheSite
|
||||
{
|
||||
public function __construct(private readonly IpBans $bans) {}
|
||||
|
||||
/**
|
||||
* @param Closure(Request): Response $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$ban = $this->bans->wholeSite($request->ip());
|
||||
|
||||
if ($ban === null) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$this->bans->knocked($ban);
|
||||
|
||||
return RefuseBannedAddress::answer($request, $ban);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user