8000 [Security] Improve exception when rate-limiter is not installed and throttling enabled by fabpot · Pull Request #38356 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Improve exception when rate-limiter is not installed and throttling enabled #38356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Security] Improve exceptionwhen rate-limiter is not installed and th…
…rottling enabled
  • Loading branch information
fabpot committed Sep 30, 2020
commit 186ecc108b9a4847c2d1c724bd1e54faa6f73db8
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\RateLimiter\Limiter;
use Symfony\Component\Security\Http\EventListener\LoginThrottlingListener;

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

if (!class_exists(Limiter::class)) {
throw new \LogicException('Login throttling requires symfony/rate-limiter to be installed and enabled.');
}

if (!isset($config['limiter'])) {
if (!class_exists(FrameworkExtension::class) || !method_exists(FrameworkExtension::class, 'registerRateLimiter')) {
throw new \LogicException('You must either configure a rate limiter for "security.firewalls.'.$firewallName.'.login_throttling" or install symfony/framework-bundle:^5.2');
throw new \LogicException('You must either configure a rate limiter for "security.firewalls.'.$firewallName.'.login_throttling" or install symfony/framework-bundle:^5.2.');
}

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