fix: ajouter log détaillé sur SSO InvalidState pour diagnostic
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -19,18 +19,21 @@ use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPasspor
|
||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use KnpU\OAuth2ClientBundle\Security\Exception\InvalidStateAuthenticationException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class KeycloakAuthenticator extends OAuth2Authenticator implements AuthenticationEntryPointInterface
|
||||
{
|
||||
private $clientRegistry;
|
||||
private $entityManager;
|
||||
private $router;
|
||||
private $logger;
|
||||
|
||||
public function __construct(ClientRegistry $clientRegistry, EntityManagerInterface $entityManager, RouterInterface $router)
|
||||
public function __construct(ClientRegistry $clientRegistry, EntityManagerInterface $entityManager, RouterInterface $router, LoggerInterface $logger)
|
||||
{
|
||||
$this->clientRegistry = $clientRegistry;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->router = $router;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function supports(Request $request): ?bool
|
||||
@@ -93,6 +96,11 @@ class KeycloakAuthenticator extends OAuth2Authenticator implements Authenticatio
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
|
||||
{
|
||||
if ($exception instanceof InvalidStateAuthenticationException) {
|
||||
$this->logger->error('SSO Invalid State', [
|
||||
'session_id' => $request->getSession()->getId(),
|
||||
'has_session' => $request->hasSession(),
|
||||
'state_param' => $request->query->get('state'),
|
||||
]);
|
||||
return new RedirectResponse($this->router->generate('app_home'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user