diff --git a/.env b/.env index 67830a468d2c19b7c2d3d7917a66910401552229..755599c6eaf2e5ba18e5ee05860e863afddf7e26 100644 --- a/.env +++ b/.env @@ -26,3 +26,9 @@ APP_SECRET=f29e104c2042ee548893fe7a0d0a7106 DATABASE_URL="mysql://root:password@127.0.0.1:8888/teebblog?serverVersion=5.7" # DATABASE_URL="postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=13&charset=utf8" ###< doctrine/doctrine-bundle ### + +###> symfony/lock ### +# Choose one of the stores below +# postgresql+advisory://db_user:db_password@localhost/db_name +LOCK_DSN=semaphore +###< symfony/lock ### diff --git a/composer.json b/composer.json index 454e0ce86acb87f46d71733e37eaff740614617f..f7759d86afd71f503c30705ab641207da177d290 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "symfony/framework-bundle": "5.3.*", "symfony/mime": "5.3.*", "symfony/proxy-manager-bridge": "5.3.*", + "symfony/rate-limiter": "5.3.*", "symfony/runtime": "5.3.*", "symfony/twig-bundle": "5.3.*", "symfony/validator": "5.3.*", diff --git a/composer.lock b/composer.lock index dcfabe1f2bd104987bc22279b86a8a92f835b70d..ea4fae9318a22b55625db683bc67d8909ef81711 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7cb9422b836ebd01c3e1561b51ca38ea", + "content-hash": "366b55e9b63d5e2f0c27659b76ae7128", "packages": [ { "name": "composer/package-versions-deprecated", @@ -4593,6 +4593,92 @@ ], "time": "2021-05-27T12:28:50+00:00" }, + { + "name": "symfony/lock", + "version": "v5.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/lock.git", + "reference": "1f166823d4307eecd9f964804afefa2a59b9a3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/lock/zipball/1f166823d4307eecd9f964804afefa2a59b9a3cf", + "reference": "1f166823d4307eecd9f964804afefa2a59b9a3cf", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "psr/log": "~1.0", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-php80": "^1.15" + }, + "conflict": { + "doctrine/dbal": "<2.10" + }, + "require-dev": { + "doctrine/dbal": "^2.10|^3.0", + "mongodb/mongodb": "~1.1", + "predis/predis": "~1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Lock\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérémy Derussé", + "email": "jeremy@derusse.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Creates and manages locks, a mechanism to provide exclusive access to a shared resource", + "homepage": "https://symfony.com", + "keywords": [ + "cas", + "flock", + "locking", + "mutex", + "redlock", + "semaphore" + ], + "support": { + "source": "https://github.com/symfony/lock/tree/v5.3.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-06-06T09:51:56+00:00" + }, { "name": "symfony/mime", "version": "v5.3.2", @@ -5953,6 +6039,82 @@ ], "time": "2021-05-26T12:52:38+00:00" }, + { + "name": "symfony/rate-limiter", + "version": "v5.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/rate-limiter.git", + "reference": "e9226c91163495ff0b655cdae0fff682e869640b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/rate-limiter/zipball/e9226c91163495ff0b655cdae0fff682e869640b", + "reference": "e9226c91163495ff0b655cdae0fff682e869640b", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2.5", + "symfony/lock": "^5.2", + "symfony/options-resolver": "^5.1" + }, + "require-dev": { + "psr/cache": "^1.0|^2.0|^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\RateLimiter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Wouter de Jong", + "email": "wouter@wouterj.nl" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides a Token Bucket implementation to rate limit input and output in your application", + "homepage": "https://symfony.com", + "keywords": [ + "limiter", + "rate-limiter" + ], + "support": { + "source": "https://github.com/symfony/rate-limiter/tree/v5.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-26T17:43:10+00:00" + }, { "name": "symfony/routing", "version": "v5.3.0", diff --git a/config/packages/lock.yaml b/config/packages/lock.yaml new file mode 100644 index 0000000000000000000000000000000000000000..574879f835c05a25f4f38b3989abfebc9fda09d5 --- /dev/null +++ b/config/packages/lock.yaml @@ -0,0 +1,2 @@ +framework: + lock: '%env(LOCK_DSN)%' diff --git a/config/packages/security.yaml b/config/packages/security.yaml index e25418bd4567e15a42f43d5db381a233c01568a8..9f296e6b7759b6a7adcbe181ec16b32c99e3c515 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -24,6 +24,8 @@ security: secret: '%kernel.secret%' lifetime: 604800 # 1 week in seconds path: / + login_throttling: + max_attempts: 3 logout: path: app_logout # where to redirect after logout diff --git a/symfony.lock b/symfony.lock index d33b76b5154fd713ab815c2a78d929ef26099e4b..ff88cc1ee320bb74e3365648d2cc01d4124be446 100644 --- a/symfony.lock +++ b/symfony.lock @@ -407,6 +407,18 @@ "symfony/intl": { "version": "v5.3.0" }, + "symfony/lock": { + "version": "5.2", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "master", + "version": "5.2", + "ref": "a1c8800e40ae735206bb14586fdd6c4630a51b8d" + }, + "files": [ + "config/packages/lock.yaml" + ] + }, "symfony/maker-bundle": { "version": "1.0", "recipe": { @@ -512,6 +524,9 @@ "symfony/proxy-manager-bridge": { "version": "v5.3.0" }, + "symfony/rate-limiter": { + "version": "v5.3.0" + }, "symfony/routing": { "version": "5.3", "recipe": {