8000 bug #38356 [Security] Improve exception when rate-limiter is not inst… · symfony/symfony@3c7a131 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c7a131

Browse files
committed
bug #38356 [Security] Improve exception when rate-limiter is not installed and throttling enabled (fabpot)
This PR was merged into the 5.2-dev branch. Discussion ---------- [Security] Improve exception when rate-limiter is not installed and throttling enabled | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes-ish | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | n/a When the rate-limiter component is not installed and if one enables login throttling, the error message is not easy to understand: `Service "limiter._login_local_main": Parent definition "limiter" does not exist.`. This fixes the error message to be easier to understand. /cc @wouterj Commits ------- 186ecc1 [Security] Improve exceptionwhen rate-limiter is not installed and throttling enabled
2 parents f06f2f0 + 186ecc1 commit 3c7a131

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Bundle/SecurityBundle/Depende 8000 ncyInjection/Security/Factory/LoginThrottlingFactory.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\DependencyInjection\ChildDefinition;
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
1919
use Symfony\Component\DependencyInjection\Reference;
20+
use Symfony\Component\RateLimiter\Limiter;
2021
use Symfony\Component\Security\Http\EventListener\LoginThrottlingListener;
2122

2223
/**
@@ -60,9 +61,13 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal
6061
throw new \LogicException('Login throttling requires symfony/security-http:^5.2.');
6162
}
6263

64+
if (!class_exists(Limiter::class)) {
65+
throw new \LogicException('Login throttling requires symfony/rate-limiter to be installed and enabled.');
66+
}
67+
6368
if (!isset($config['limiter'])) {
6469
if (!class_exists(FrameworkExtension::class) || !method_exists(FrameworkExtension::class, 'registerRateLimiter')) {
65-
throw new \LogicException('You must either configure a rate limiter for "security.firewalls.'.$firewallName.'.login_throttling" or install symfony/framework-bundle:^5.2');
70+
throw new \LogicException('You must either configure a rate limiter for "security.firewalls.'.$firewallName.'.login_throttling" or install symfony/framework-bundle:^5.2.');
6671
}
6772

6873
FrameworkExtension::registerRateLimiter($container, $config['limiter'] = '_login_'.$firewallName, [

0 commit comments

Comments
 (0)
0