Skip to content
Snippets Groups Projects
Commit 84d9aacc authored by Jaime Pérez's avatar Jaime Pérez
Browse files

Capture errors when setting the auth token cookie.

If it fails for some reason, we clear all the authentication-related data from the session, log an error, and throw again the exception, so that the user does not continue as if anything happened when the auth token is not set.
parent 3f2621e3
No related branches found
No related tags found
No related merge requests found
......@@ -560,11 +560,23 @@ class SimpleSAML_Session
$this->setRememberMeExpire();
} else {
SimpleSAML\Utils\HTTP::setCookie(
$globalConfig->getString('session.authtoken.cookiename', 'SimpleSAMLAuthToken'),
$this->authToken,
$sessionHandler->getCookieParams()
);
try {
SimpleSAML\Utils\HTTP::setCookie(
$globalConfig->getString('session.authtoken.cookiename', 'SimpleSAMLAuthToken'),
$this->authToken,
$sessionHandler->getCookieParams()
);
} catch (SimpleSAML\Error\CannotSetCookie $e) {
/*
* Something went wrong when setting the auth token. We cannot recover from this, so we better log a
* message and throw an exception. The user is not properly logged in anyway, so clear all login
* information from the session.
*/
unset($this->authToken);
unset($this->authData[$authority]);
\SimpleSAML\Logger::error('Cannot set authentication token cookie: '.$e->getMessage());
throw $e;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment