205 lines
8.7 KiB
Diff
205 lines
8.7 KiB
Diff
From abfddd90073a3f3056526429b1b9dc4aa5c252b9 Mon Sep 17 00:00:00 2001
|
|
From: chris <cg@zknt.org>
|
|
Date: Wed, 24 Jan 2024 13:00:53 +0100
|
|
Subject: [PATCH 1/6] remove IP logging
|
|
|
|
Replace unneeded logging of IPs and User-Agent strings with meaningless static data.
|
|
---
|
|
app/Http/Controllers/Api/ApiV1Dot1Controller.php | 16 ++++++++--------
|
|
app/Http/Controllers/Auth/LoginController.php | 4 ++--
|
|
app/Http/Controllers/RemoteAuthController.php | 4 ++--
|
|
app/Http/Controllers/SeasonalController.php | 4 ++--
|
|
app/Http/Controllers/Settings/HomeSettings.php | 8 ++++----
|
|
.../Controllers/UserEmailForgotController.php | 4 ++--
|
|
app/Listeners/AuthLogin.php | 4 ++--
|
|
app/Listeners/LogFailedLogin.php | 4 ++--
|
|
8 files changed, 24 insertions(+), 24 deletions(-)
|
|
|
|
diff --git a/app/Http/Controllers/Api/ApiV1Dot1Controller.php b/app/Http/Controllers/Api/ApiV1Dot1Controller.php
|
|
index 75d0fe98..88948276 100644
|
|
--- a/app/Http/Controllers/Api/ApiV1Dot1Controller.php
|
|
+++ b/app/Http/Controllers/Api/ApiV1Dot1Controller.php
|
|
@@ -280,8 +280,8 @@ class ApiV1Dot1Controller extends Controller
|
|
$log->action = 'account.edit.password';
|
|
$log->message = 'Password changed';
|
|
$log->link = null;
|
|
- $log->ip_address = $request->ip();
|
|
- $log->user_agent = $request->userAgent();
|
|
+ $log->ip_address = "127.0.0.23";
|
|
+ $log->user_agent = "Pixelfed.de";
|
|
$log->save();
|
|
|
|
Mail::to($request->user())->send(new PasswordChange($user));
|
|
@@ -303,7 +303,7 @@ class ApiV1Dot1Controller extends Controller
|
|
abort_if(BouncerService::checkIp($request->ip()), 404);
|
|
}
|
|
$agent = new Agent();
|
|
- $currentIp = $request->ip();
|
|
+ $currentIp = "127.0.0.23";
|
|
|
|
$activity = AccountLog::whereUserId($user->id)
|
|
->whereAction('auth.login')
|
|
@@ -316,8 +316,8 @@ class ApiV1Dot1Controller extends Controller
|
|
return [
|
|
'id' => $item->id,
|
|
'action' => $item->action,
|
|
- 'ip' => $item->ip_address,
|
|
- 'ip_current' => $item->ip_address === $currentIp,
|
|
+ 'ip' => "127.0.0.23",
|
|
+ 'ip_current' => "127.0.0.23" === $currentIp,
|
|
'is_mobile' => $agent->isMobile(),
|
|
'device' => $agent->device(),
|
|
'browser' => $agent->browser(),
|
|
@@ -474,7 +474,7 @@ class ApiV1Dot1Controller extends Controller
|
|
abort_if(BouncerService::checkIp($request->ip()), 404);
|
|
}
|
|
|
|
- $rl = RateLimiter::attempt('pf:apiv1.1:iar:'.$request->ip(), config('pixelfed.app_registration_rate_limit_attempts', 3), function(){}, config('pixelfed.app_registration_rate_limit_decay', 1800));
|
|
+ $rl = RateLimiter::attempt('pf:apiv1.1:iar:'.Str::Random(10), config('pixelfed.app_registration_rate_limit_attempts', 3), function(){}, config('pixelfed.app_registration_rate_limit_decay', 1800));
|
|
abort_if(!$rl, 400, 'Too many requests');
|
|
|
|
$this->validate($request, [
|
|
@@ -546,7 +546,7 @@ class ApiV1Dot1Controller extends Controller
|
|
$user->email = $email;
|
|
$user->password = Hash::make($password);
|
|
$user->register_source = 'app';
|
|
- $user->app_register_ip = $request->ip();
|
|
+ $user->app_register_ip = "127.0.0.23";
|
|
$user->app_register_token = Str::random(40);
|
|
$user->save();
|
|
|
|
@@ -603,7 +603,7 @@ class ApiV1Dot1Controller extends Controller
|
|
abort_if(BouncerService::checkIp($request->ip()), 404);
|
|
}
|
|
|
|
- $rl = RateLimiter::attempt('pf:apiv1.1:iarc:'.$request->ip(), config('pixelfed.app_registration_confirm_rate_limit_attempts', 20), function(){}, config('pixelfed.app_registration_confirm_rate_limit_decay', 1800));
|
|
+ $rl = RateLimiter::attempt('pf:apiv1.1:iarc:'.Str::Random(10), config('pixelfed.app_registration_confirm_rate_limit_attempts', 20), function(){}, config('pixelfed.app_registration_confirm_rate_limit_decay', 1800));
|
|
abort_if(!$rl, 429, 'Too many requests');
|
|
|
|
$this->validate($request, [
|
|
diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php
|
|
index 627a879c..1d7af486 100644
|
|
--- a/app/Http/Controllers/Auth/LoginController.php
|
|
+++ b/app/Http/Controllers/Auth/LoginController.php
|
|
@@ -109,8 +109,8 @@ class LoginController extends Controller
|
|
$log->action = 'auth.login';
|
|
$log->message = 'Account Login';
|
|
$log->link = null;
|
|
- $log->ip_address = $request->ip();
|
|
- $log->user_agent = $request->userAgent();
|
|
+ $log->ip_address = "127.0.0.23";
|
|
+ $log->user_agent = "Pixelfed.de";
|
|
$log->save();
|
|
}
|
|
|
|
diff --git a/app/Http/Controllers/RemoteAuthController.php b/app/Http/Controllers/RemoteAuthController.php
|
|
index e068f5d7..37e4dfad 100644
|
|
--- a/app/Http/Controllers/RemoteAuthController.php
|
|
+++ b/app/Http/Controllers/RemoteAuthController.php
|
|
@@ -320,7 +320,7 @@ class RemoteAuthController extends Controller
|
|
'webfinger' => $res['_webfinger'],
|
|
], [
|
|
'software' => 'mastodon',
|
|
- 'ip_address' => $request->ip(),
|
|
+ 'ip_address' => "127.0.0.23",
|
|
'bearer_token' => $token,
|
|
'verify_credentials' => $res,
|
|
'last_verify_credentials_at' => now(),
|
|
@@ -702,7 +702,7 @@ class RemoteAuthController extends Controller
|
|
'email' => $data['email'],
|
|
'password' => Hash::make($data['password']),
|
|
'email_verified_at' => config('remote-auth.mastodon.contraints.skip_email_verification') ? now() : null,
|
|
- 'app_register_ip' => request()->ip(),
|
|
+ 'app_register_ip' => "127.0.0.23",
|
|
'register_source' => 'mastodon'
|
|
])));
|
|
|
|
diff --git a/app/Http/Controllers/SeasonalController.php b/app/Http/Controllers/SeasonalController.php
|
|
index a9f1f98c..c3c4cc43 100644
|
|
--- a/app/Http/Controllers/SeasonalController.php
|
|
+++ b/app/Http/Controllers/SeasonalController.php
|
|
@@ -230,8 +230,8 @@ class SeasonalController extends Controller
|
|
'action' => 'seasonal.my2020.view'
|
|
],
|
|
[
|
|
- 'ip_address' => $request->ip(),
|
|
- 'user_agent' => $request->userAgent()
|
|
+ 'ip_address' => "127.0.0.23",
|
|
+ 'user_agent' => "Pixelfed.de"
|
|
]
|
|
]);
|
|
return response()->json(200);
|
|
diff --git a/app/Http/Controllers/Settings/HomeSettings.php b/app/Http/Controllers/Settings/HomeSettings.php
|
|
index 99326c09..6fc5030b 100644
|
|
--- a/app/Http/Controllers/Settings/HomeSettings.php
|
|
+++ b/app/Http/Controllers/Settings/HomeSettings.php
|
|
@@ -139,8 +139,8 @@ trait HomeSettings
|
|
$log->action = 'account.edit.password';
|
|
$log->message = 'Password changed';
|
|
$log->link = null;
|
|
- $log->ip_address = $request->ip();
|
|
- $log->user_agent = $request->userAgent();
|
|
+ $log->ip_address = "127.0.0.23";
|
|
+ $log->user_agent = "Pixelfed.de";
|
|
$log->save();
|
|
|
|
Mail::to($request->user())->send(new PasswordChange($user));
|
|
@@ -186,8 +186,8 @@ trait HomeSettings
|
|
$log->action = 'account.edit.email';
|
|
$log->message = 'Email changed';
|
|
$log->link = null;
|
|
- $log->ip_address = $request->ip();
|
|
- $log->user_agent = $request->userAgent();
|
|
+ $log->ip_address = "127.0.0.23";
|
|
+ $log->user_agent = "Pixelfed.de";
|
|
$log->save();
|
|
}
|
|
|
|
diff --git a/app/Http/Controllers/UserEmailForgotController.php b/app/Http/Controllers/UserEmailForgotController.php
|
|
index 33378c4d..e6f1be45 100644
|
|
--- a/app/Http/Controllers/UserEmailForgotController.php
|
|
+++ b/app/Http/Controllers/UserEmailForgotController.php
|
|
@@ -80,8 +80,8 @@ class UserEmailForgotController extends Controller
|
|
{
|
|
UserEmailForgot::create([
|
|
'user_id' => $user->id,
|
|
- 'ip_address' => $request->ip(),
|
|
- 'user_agent' => $request->userAgent(),
|
|
+ 'ip_address' => "127.0.0.23",
|
|
+ 'user_agent' => "Pixelfed.de",
|
|
'email_sent_at' => now()
|
|
]);
|
|
|
|
diff --git a/app/Listeners/AuthLogin.php b/app/Listeners/AuthLogin.php
|
|
index 90806965..ffc67d79 100644
|
|
--- a/app/Listeners/AuthLogin.php
|
|
+++ b/app/Listeners/AuthLogin.php
|
|
@@ -122,8 +122,8 @@ class AuthLogin
|
|
$device = DB::transaction(function() use($user) {
|
|
return UserDevice::firstOrCreate([
|
|
'user_id' => $user->id,
|
|
- 'ip' => request()->ip(),
|
|
- 'user_agent' => str_limit(request()->userAgent(), 180),
|
|
+ 'ip' => "127.0.0.23",
|
|
+ 'user_agent' => "Pixelfed.de",
|
|
]);
|
|
});
|
|
}
|
|
diff --git a/app/Listeners/LogFailedLogin.php b/app/Listeners/LogFailedLogin.php
|
|
index c6ba3305..9442bfd0 100644
|
|
--- a/app/Listeners/LogFailedLogin.php
|
|
+++ b/app/Listeners/LogFailedLogin.php
|
|
@@ -41,8 +41,8 @@ class LogFailedLogin
|
|
$log->action = 'auth.failed';
|
|
$log->message = 'Failed login attempt';
|
|
$log->link = null;
|
|
- $log->ip_address = $request->ip();
|
|
- $log->user_agent = $request->userAgent();
|
|
+ $log->ip_address = "127.0.0.23";
|
|
+ $log->user_agent = "Pixelfed.de";
|
|
$log->save();
|
|
}
|
|
}
|
|
--
|
|
2.43.0
|