Harden the app: block project files, add rate limits and security headers
- Root .htaccess refuses everything outside public/, because local Apache serves the whole project folder (.env, logs with set-password links, .git). - Login allows 20 failed attempts a minute per IP across accounts, besides 5 per email and IP; the forgot-password page 5 requests a minute per IP. - A global middleware sends X-Frame-Options, frame-ancestors, nosniff, Referrer-Policy, Permissions-Policy and HSTS over HTTPS, and drops X-Powered-By. - The weekly time sheet locks the shown week and selected day, so the browser cannot set them. - Users who may not see personal identity codes can save a new code at most 10 times an hour, so the duplicate check cannot be used to test codes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -90,6 +90,23 @@ it('blocks login after five failed attempts', function () {
|
||||
$this->assertGuest();
|
||||
});
|
||||
|
||||
it('blocks one address that tries a password on many accounts', function () {
|
||||
RateLimiter::clear('login-ip|127.0.0.1');
|
||||
User::factory()->create(['email' => '[email protected]']);
|
||||
$login = Livewire::test('users::login');
|
||||
|
||||
foreach (range(1, 20) as $attempt) {
|
||||
$login->set('email', "tuntematon{$attempt}@example.test")->set('password', 'Kesä2027!')->call('login');
|
||||
}
|
||||
|
||||
$login->set('email', '[email protected]')
|
||||
->set('password', 'password')
|
||||
->call('login')
|
||||
->assertSee('Liian monta kirjautumisyritystä.');
|
||||
|
||||
$this->assertGuest();
|
||||
});
|
||||
|
||||
it('ends the session of a user who is deactivated while signed in', function () {
|
||||
$user = User::factory()->create();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user