mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: json login rate limit
This commit is contained in:
@@ -1,3 +1,27 @@
|
|||||||
|
framework:
|
||||||
|
rate_limiter:
|
||||||
|
# define 2 rate limiters (one for username+IP, the other for IP)
|
||||||
|
username_ip_login:
|
||||||
|
policy: token_bucket
|
||||||
|
limit: 5
|
||||||
|
rate: { interval: '5 minutes' }
|
||||||
|
|
||||||
|
ip_login:
|
||||||
|
policy: sliding_window
|
||||||
|
limit: 50
|
||||||
|
interval: '15 minutes'
|
||||||
|
|
||||||
|
services:
|
||||||
|
# our custom login rate limiter
|
||||||
|
app.login_rate_limiter:
|
||||||
|
class: Symfony\Component\Security\Http\RateLimiter\DefaultLoginRateLimiter
|
||||||
|
arguments:
|
||||||
|
# globalFactory is the limiter for IP
|
||||||
|
$globalFactory: '@limiter.ip_login'
|
||||||
|
# localFactory is the limiter for username+IP
|
||||||
|
$localFactory: '@limiter.username_ip_login'
|
||||||
|
$secret: '%kernel.secret%'
|
||||||
|
|
||||||
security:
|
security:
|
||||||
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
|
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
|
||||||
password_hashers:
|
password_hashers:
|
||||||
@@ -21,6 +45,8 @@ security:
|
|||||||
check_path: api_login
|
check_path: api_login
|
||||||
success_handler: lexik_jwt_authentication.handler.authentication_success
|
success_handler: lexik_jwt_authentication.handler.authentication_success
|
||||||
failure_handler: lexik_jwt_authentication.handler.authentication_failure
|
failure_handler: lexik_jwt_authentication.handler.authentication_failure
|
||||||
|
login_throttling:
|
||||||
|
limiter: app.login_rate_limiter
|
||||||
|
|
||||||
api:
|
api:
|
||||||
pattern: ^/api
|
pattern: ^/api
|
||||||
|
|||||||
Reference in New Issue
Block a user