Skip to content

Commit 53b35a5

Browse files
limit login attempts
1 parent d551e7f commit 53b35a5

File tree

7 files changed

+179
-5
lines changed

7 files changed

+179
-5
lines changed

.env.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ APP_SECRET=fda41e68dccbce19b1829cb12cc5d89f
2222
MAILER_DSN=null://null
2323
###< symfony/mailer ###
2424

25+
###> symfony/lock ###
26+
# Choose one of the stores below
27+
# postgresql+advisory://db_user:db_password@localhost/db_name
28+
LOCK_DSN=semaphore
29+
###< symfony/lock ###
30+
2531
###> app ###
2632
INSTALLATION_TYPE=source
2733
ELASTICSEARCH_URL=http://localhost:9200

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"prefer-stable": true,
99
"require": {
1010
"php": ">=8.0.2",
11-
"composer-runtime-api": ">=2.1",
1211
"ext-ctype": "*",
1312
"ext-iconv": "*",
13+
"composer-runtime-api": ">=2.1",
1414
"box/spout": "^3.1",
1515
"matomo/device-detector": "^5.0",
1616
"minishlink/web-push": "^6.0.1",
@@ -27,6 +27,7 @@
2727
"symfony/mailer": "6.0.*",
2828
"symfony/monolog-bundle": "^3.1",
2929
"symfony/process": "6.0.*",
30+
"symfony/rate-limiter": "6.0.*",
3031
"symfony/runtime": "6.0.*",
3132
"symfony/security-bundle": "6.0.*",
3233
"symfony/serializer": "6.0.*",

composer.lock

Lines changed: 150 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/packages/lock.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
framework:
2+
lock: '%env(LOCK_DSN)%'

config/packages/security.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ security:
1818
custom_authenticator: App\Security\AppCustomAuthenticator
1919
logout:
2020
path: app_logout
21+
login_throttling:
22+
max_attempts: 3
23+
interval: '5 minutes'
2124

2225
# activate different ways to authenticate
2326
# https://symfony.com/doc/current/security.html#the-firewall

src/Controller/AppSecurityController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function login(Request $request, AuthenticationUtils $authenticationUtils
5252
}
5353

5454
if ($error = $authenticationUtils->getLastAuthenticationError()) {
55-
$this->addFlash('danger', $error->getMessageKey());
55+
$this->addFlash('danger', strtr($error->getMessageKey(), $error->getMessageData()));
5656
}
5757

5858
$lastUsername = $authenticationUtils->getLastUsername();

symfony.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@
317317
"symfony/intl": {
318318
"version": "v5.0.5"
319319
},
320+
"symfony/lock": {
321+
"version": "6.0",
322+
"recipe": {
323+
"repo": "github.com/symfony/recipes",
324+
"branch": "master",
325+
"version": "5.2",
326+
"ref": "a1c8800e40ae735206bb14586fdd6c4630a51b8d"
327+
},
328+
"files": [
329+
"config/packages/lock.yaml"
330+
]
331+
},
320332
"symfony/mailer": {
321333
"version": "4.3",
322334
"recipe": {
@@ -407,6 +419,9 @@
407419
"symfony/property-info": {
408420
"version": "v5.0.5"
409421
},
422+
"symfony/rate-limiter": {
423+
"version": "v6.0.3"
424+
},
410425
"symfony/routing": {
411426
"version": "6.0",
412427
"recipe": {

0 commit comments

Comments
 (0)