From 572688f5ac815f590d1266ed755826ad205ee617 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Mon, 21 Jul 2025 14:29:20 +0200 Subject: [PATCH] add warning log with more data when there is a state mismatch Signed-off-by: Julien Veyssier --- lib/Controller/LoginController.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Controller/LoginController.php b/lib/Controller/LoginController.php index 4ab20f8ed..1e1941ed7 100644 --- a/lib/Controller/LoginController.php +++ b/lib/Controller/LoginController.php @@ -328,8 +328,14 @@ public function code(string $state = '', string $code = '', string $scope = '', return $this->build403TemplateResponse($message, Http::STATUS_BAD_REQUEST, [], false); } - if ($this->session->get(self::STATE) !== $state) { - $this->logger->debug('state does not match'); + $storedState = $this->session->get(self::STATE); + + if ($storedState !== $state) { + $this->logger->warning('state does not match', [ + 'got' => $state, + 'expected' => $storedState, + 'state_exists_in_session' => $this->session->exists(self::STATE), + ]); $message = $this->l10n->t('The received state does not match the expected value.'); if ($this->isDebugModeEnabled()) { @@ -337,7 +343,8 @@ public function code(string $state = '', string $code = '', string $scope = '', 'error' => 'invalid_state', 'error_description' => $message, 'got' => $state, - 'expected' => $this->session->get(self::STATE), + 'expected' => $storedState, + 'state_exists_in_session' => $this->session->exists(self::STATE), ]; return new JSONResponse($responseData, Http::STATUS_FORBIDDEN); }