Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions lib/Controller/SAMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,23 +361,25 @@ 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;
}
$this->logger->debug('Attributes provisioned', ['app' => 'user_saml', 'attributes' => $auth->getAttributes()]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already logged in line 347


$this->session->set('user_saml.samlUserData', $auth->getAttributes());
$this->session->set('user_saml.samlNameId', $auth->getNameId());
Expand All @@ -386,6 +388,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 +403,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