Skip to content
New issue

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

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

Already on GitHub? # to your account

fix: Add more logging to the saml/acs endpoint #885

Merged
merged 1 commit into from
Oct 8, 2024
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
7 changes: 5 additions & 2 deletions lib/Controller/SAMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,20 @@ 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.
try {
$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;
Expand All @@ -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();
Expand All @@ -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 !== '') {
Expand Down
Loading