fix(api): use the Cloudflare client IP for allowed IPs and audit logs

Closes #12301

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-10-25 23:47:39 +01:00
co-authored by Claude Opus 5.5
parent 0f0a1e920d
commit 80ce0efe7e
12 changed files with 77 additions and 23 deletions
@@ -51,7 +51,7 @@ trait ThrottlesManualWebhookFailures
/**
* The connection address of the client. X-Forwarded-For is ignored, since
* any client can set it and rotate it to get a new bucket. On cloud, a
* valid CF-Connecting-IP is used, as in auth_rate_limit_ip().
* valid CF-Connecting-IP is used.
*/
protected function manualWebhookFailureClientAddress(Request $request): string
{
+1 -1
View File
@@ -22,7 +22,7 @@ class ApiIpAllowed
$allowedIps = array_filter(array_map('trim', explode(',', $allowedIps)));
if (! empty($allowedIps) && ! checkIPAgainstAllowlist($request->ip(), $allowedIps)) {
if (! empty($allowedIps) && ! checkIPAgainstAllowlist(client_ip($request), $allowedIps)) {
return response()->json(['success' => true, 'message' => 'You are not allowed to access the API.'], 403);
}