Skip to content

Commit 51546c8

Browse files
committed
Merge branch '4.x' into 5.x
2 parents 529c29d + 0fd67ee commit 51546c8

File tree

2 files changed

+0
-79
lines changed

2 files changed

+0
-79
lines changed

packages/panels/src/Auth/Pages/Login.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ public function authenticate(): ?LoginResponse
7878

7979
$data = $this->form->getState();
8080

81-
if ($this->isLoginRateLimited($data['email'])) {
82-
return null;
83-
}
84-
8581
/** @var SessionGuard $authGuard */
8682
$authGuard = Filament::auth();
8783

@@ -164,26 +160,6 @@ protected function isMultiFactorChallengeRateLimited(Authenticatable $user): boo
164160
return false;
165161
}
166162

167-
protected function isLoginRateLimited(string $email): bool
168-
{
169-
$rateLimitingKey = 'filament-login:' . sha1(request()->ip() . '|' . $email);
170-
171-
if (RateLimiter::tooManyAttempts($rateLimitingKey, maxAttempts: 5)) {
172-
$this->getRateLimitedNotification(new TooManyRequestsException(
173-
static::class,
174-
'authenticate',
175-
request()->ip(),
176-
RateLimiter::availableIn($rateLimitingKey),
177-
))?->send();
178-
179-
return true;
180-
}
181-
182-
RateLimiter::hit($rateLimitingKey);
183-
184-
return false;
185-
}
186-
187163
protected function getRateLimitedNotification(TooManyRequestsException $exception): ?Notification
188164
{
189165
return Notification::make()

tests/src/Panels/Auth/LoginTest.php

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -215,61 +215,6 @@
215215
->assertNoAccessibilityIssues();
216216
});
217217

218-
it('can throttle login attempts per IP and email', function (): void {
219-
$this->assertGuest();
220-
221-
$userToAuthenticate = User::factory()->create();
222-
223-
// Clear the IP-only rate limiter between attempts to isolate the
224-
// IP+email rate limit.
225-
$clearIpRateLimiter = function (): void {
226-
RateLimiter::clear('livewire-rate-limiter:' . sha1(Login::class . '|authenticate|' . request()->ip()));
227-
};
228-
229-
foreach (range(1, 5) as $i) {
230-
$clearIpRateLimiter();
231-
232-
livewire(Login::class)
233-
->fillForm([
234-
'email' => $userToAuthenticate->email,
235-
'password' => 'password',
236-
])
237-
->call('authenticate');
238-
239-
$this->assertAuthenticated();
240-
241-
auth()->logout();
242-
}
243-
244-
$clearIpRateLimiter();
245-
246-
// The 6th attempt from the same IP + email should be rate limited
247-
livewire(Login::class)
248-
->fillForm([
249-
'email' => $userToAuthenticate->email,
250-
'password' => 'password',
251-
])
252-
->call('authenticate')
253-
->assertNotified();
254-
255-
$this->assertGuest();
256-
257-
$clearIpRateLimiter();
258-
259-
// A different email from the same IP should not be affected
260-
$secondUser = User::factory()->create();
261-
262-
livewire(Login::class)
263-
->fillForm([
264-
'email' => $secondUser->email,
265-
'password' => 'password',
266-
])
267-
->call('authenticate')
268-
->assertRedirect(Filament::getUrl());
269-
270-
$this->assertAuthenticatedAs($secondUser);
271-
});
272-
273218
it('does not lock out a user when an attacker exhausts login attempts from a different IP', function (): void {
274219
$this->assertGuest();
275220

0 commit comments

Comments
 (0)