From e72ad44310f84045749b9f692f3009b7b4985b7e Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 16 Sep 2024 20:49:37 +0200 Subject: [PATCH] fix: Add more logging to the saml/acs endpoint Signed-off-by: Christoph Wurst --- lib/Controller/SAMLController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Controller/SAMLController.php b/lib/Controller/SAMLController.php index 4bdeba69..de5b0ca8 100644 --- a/lib/Controller/SAMLController.php +++ b/lib/Controller/SAMLController.php @@ -361,6 +361,7 @@ public function assertionConsumerService(): Http\RedirectResponse { $response->invalidateCookie('saml_data'); return $response; } + $this->logger->debug('Authentication successful', ['app' => 'user_saml']); // Check whether the user actually exists, if not redirect to an error page // explaining the issue. @@ -368,12 +369,12 @@ public function assertionConsumerService(): Http\RedirectResponse { $this->userData->setAttributes($auth->getAttributes()); $this->autoprovisionIfPossible(); } catch (NoUserFoundException $e) { - $this->logger->error($e->getMessage(), ['app' => $this->appName]); + $this->logger->error($e->getMessage(), ['app' => $this->appName, 'exception' => $e]); $response = new Http\RedirectResponse($this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.notProvisioned')); $response->invalidateCookie('saml_data'); return $response; } catch (UserFilterViolationException $e) { - $this->logger->error($e->getMessage(), ['app' => $this->appName]); + $this->logger->error($e->getMessage(), ['app' => $this->appName, 'exception' => $e]); $response = new Http\RedirectResponse($this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.notPermitted')); $response->invalidateCookie('saml_data'); return $response; @@ -386,6 +387,7 @@ public function assertionConsumerService(): Http\RedirectResponse { $this->session->set('user_saml.samlNameIdSPNameQualifier', $auth->getNameIdSPNameQualifier()); $this->session->set('user_saml.samlSessionIndex', $auth->getSessionIndex()); $this->session->set('user_saml.samlSessionExpiration', $auth->getSessionExpiration()); + $this->logger->debug('Session values set', ['app' => 'user_saml']); try { $user = $this->userResolver->findExistingUser($this->userBackend->getCurrentUserId()); $firstLogin = $user->updateLastLoginTimestamp(); @@ -400,6 +402,7 @@ public function assertionConsumerService(): Http\RedirectResponse { $response->invalidateCookie('saml_data'); return $response; } + $this->logger->debug('User found, last login timestamp updated', ['app' => 'user_saml']); $originalUrl = $data['RelayState'] ?? $data['OriginalUrl']; if ($originalUrl !== null && $originalUrl !== '') {