Skip to content
Snippets Groups Projects
Commit fd1e3a6b authored by Andjelko Horvat's avatar Andjelko Horvat
Browse files

Add session.disable_fallback option (issue #492).

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3082 44740490-163a-0410-bde0-09ae8108e29a
parent 78a53563
No related branches found
No related tags found
No related merge requests found
...@@ -240,6 +240,12 @@ $config = array ( ...@@ -240,6 +240,12 @@ $config = array (
*/ */
'session.cookie.secure' => FALSE, 'session.cookie.secure' => FALSE,
/*
* When set to FALSE fallback to transient session on session initialization
* failure, throw exception otherwise.
*/
'session.disable_fallback' => FALSE,
/* /*
* Enable secure POST from HTTPS to HTTP. * Enable secure POST from HTTPS to HTTP.
* *
......
...@@ -45,6 +45,14 @@ class SimpleSAML_Session { ...@@ -45,6 +45,14 @@ class SimpleSAML_Session {
private $sessionId; private $sessionId;
/**
* Transient session flag.
*
* @var boolean|FALSE
*/
private $transient = FALSE;
/** /**
* The track id is a new random unique identifier that is generate for each session. * The track id is a new random unique identifier that is generate for each session.
* This is used in the debug logs and error messages to easily track more information * This is used in the debug logs and error messages to easily track more information
...@@ -150,6 +158,7 @@ class SimpleSAML_Session { ...@@ -150,6 +158,7 @@ class SimpleSAML_Session {
if ($transient) { if ($transient) {
$this->trackid = 'XXXXXXXXXX'; $this->trackid = 'XXXXXXXXXX';
$this->transient = TRUE;
return; return;
} }
...@@ -249,14 +258,21 @@ class SimpleSAML_Session { ...@@ -249,14 +258,21 @@ class SimpleSAML_Session {
try { try {
self::$instance = self::getSession(); self::$instance = self::getSession();
} catch (Exception $e) { } catch (Exception $e) {
/* For some reason, we were unable to initialize this session. Use a transient session instead. */
self::useTransientSession();
$globalConfig = SimpleSAML_Configuration::getInstance();
if ($globalConfig->getBoolean('session.disable_fallback', FALSE) === TRUE) {
throw $e;
}
if ($e instanceof SimpleSAML_Error_Exception) { if ($e instanceof SimpleSAML_Error_Exception) {
SimpleSAML_Logger::error('Error loading session:'); SimpleSAML_Logger::error('Error loading session:');
$e->logError(); $e->logError();
} else { } else {
SimpleSAML_Logger::error('Error loading session: ' . $e->getMessage()); SimpleSAML_Logger::error('Error loading session: ' . $e->getMessage());
} }
/* For some reason, we were unable to initialize this session. Use a transient session instead. */
self::useTransientSession();
return self::$instance; return self::$instance;
} }
...@@ -299,6 +315,16 @@ class SimpleSAML_Session { ...@@ -299,6 +315,16 @@ class SimpleSAML_Session {
} }
/**
* Retrieve if session is transient.
*
* @return boolean The session transient flag.
*/
public function isTransient() {
return $this->transient;
}
/** /**
* Get a unique ID that will be permanent for this session. * Get a unique ID that will be permanent for this session.
* Used for debugging and tracing log files related to a session. * Used for debugging and tracing log files related to a session.
......
...@@ -17,19 +17,27 @@ $reportId = (string)$_REQUEST['reportId']; ...@@ -17,19 +17,27 @@ $reportId = (string)$_REQUEST['reportId'];
$email = (string)$_REQUEST['email']; $email = (string)$_REQUEST['email'];
$text = htmlspecialchars((string)$_REQUEST['text']); $text = htmlspecialchars((string)$_REQUEST['text']);
$session = SimpleSAML_Session::getInstance(); try {
$data = $session->getData('core:errorreport', $reportId); $session = SimpleSAML_Session::getInstance();
$data = $session->getData('core:errorreport', $reportId);
} catch (Exception $e) {
SimpleSAML_Logger::error('Error loading error report data: ' . var_export($e->getMessage(), TRUE));
}
if ($data === NULL) { if ($data === NULL) {
$data = array( $data = array(
'exceptionMsg' => 'not set', 'exceptionMsg' => 'not set',
'exceptionTrace' => 'not set', 'exceptionTrace' => 'not set',
'reportId' => $reportId, 'reportId' => $reportId,
'trackId' => $session->getTrackId(), 'trackId' => 'not set',
'url' => 'not set', 'url' => 'not set',
'version' => $config->getVersion(), 'version' => $config->getVersion(),
'referer' => 'not set', 'referer' => 'not set',
); );
if (isset($session)) {
$data['trackId'] = $session->getTrackId();
}
} }
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
......
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