İlk temizlik tamamlandı bir önceki projeden

This commit is contained in:
Ümit Tunç
2026-04-28 21:14:25 +03:00
commit f80443aec0
10000 changed files with 959965 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class IpFirewall
{
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next): Response
{
// İzin verilen IP listesi (Env veya Config'den alınabilir)
// Boş bırakılırsa herkese açık olur.
$allowedIpsString = config('app.allowed_api_ips', '');
if (empty($allowedIpsString)) {
return $next($request);
}
$allowedIps = explode(',', $allowedIpsString);
$clientIp = $request->ip();
if (!in_array($clientIp, $allowedIps)) {
return response()->json([
'status' => 'error',
'message' => 'Access denied. IP not allowed.',
'ip' => $clientIp
], 403);
}
return $next($request);
}
}