From 90c901634a75d813fedf6ce1372d758e73e31b2f Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Fri, 16 Feb 2024 18:21:47 +0100 Subject: [PATCH] Fix registration of failure handler --- .../Security/Factory/OAuthAuthenticatorFactory.php | 12 ++++++++++++ src/Resources/config/oauth.php | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/DependencyInjection/Security/Factory/OAuthAuthenticatorFactory.php b/src/DependencyInjection/Security/Factory/OAuthAuthenticatorFactory.php index 91903d200..28a5b1419 100644 --- a/src/DependencyInjection/Security/Factory/OAuthAuthenticatorFactory.php +++ b/src/DependencyInjection/Security/Factory/OAuthAuthenticatorFactory.php @@ -135,6 +135,18 @@ public function getFirewallNames(): \ArrayIterator return $this->firewallNames; } + protected function createAuthenticationFailureHandler(ContainerBuilder $container, string $id, array $config): string + { + $id = $this->getFailureHandlerId($id); + $options = array_intersect_key($config, $this->defaultFailureHandlerOptions); + + $failureHandler = $container->setDefinition($id, new ChildDefinition('security.authentication.custom_failure_handler')); + $failureHandler->replaceArgument(0, new ChildDefinition('hwi_oauth.authentication.failure_handler')); + $failureHandler->replaceArgument(1, $options); + + return $id; + } + /** * {@inheritdoc} */ diff --git a/src/Resources/config/oauth.php b/src/Resources/config/oauth.php index 0bd01b1f4..37fcbfece 100644 --- a/src/Resources/config/oauth.php +++ b/src/Resources/config/oauth.php @@ -62,5 +62,10 @@ ]); $services->set('hwi_oauth.authentication.failure_handler', AuthenticationFailureHandler::class) - ->arg('$connect', '%hwi_oauth.connect%'); + ->args([ + service('request_stack'), + service('router'), + service('twig'), + '%hwi_oauth.connect%' + ]); };