Revision: 3082
Author: comel.ah
Date: Thu May 3 04:53:56 2012
Log: Add session.disable_fallback option (issue #492).
http://code.google.com/p/simplesamlphp/source/detail?r=3082
Modified:
/trunk/config-templates/config.php
/trunk/lib/SimpleSAML/Session.php
/trunk/www/errorreport.php
=======================================
--- /trunk/config-templates/config.php Wed Mar 21 05:28:39 2012
+++ /trunk/config-templates/config.php Thu May 3 04:53:56 2012
@@ -240,6 +240,12 @@
*/
'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.
*
=======================================
--- /trunk/lib/SimpleSAML/Session.php Thu Apr 12 01:09:26 2012
+++ /trunk/lib/SimpleSAML/Session.php Thu May 3 04:53:56 2012
@@ -45,6 +45,14 @@
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.
* This is used in the debug logs and error messages to easily track more
information
@@ -150,6 +158,7 @@
if ($transient) {
$this->trackid = 'XXXXXXXXXX';
+ $this->transient = TRUE;
return;
}
@@ -249,14 +258,21 @@
try {
self::$instance = self::getSession();
} 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) {
SimpleSAML_Logger::error('Error loading
session:');
$e->logError();
} else {
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;
}
@@ -297,6 +313,16 @@
return $this->sessionId;
}
+
+
+ /**
+ * Retrieve if session is transient.
+ *
+ * @return boolean The session transient flag.
+ */
+ public function isTransient() {
+ return $this->transient;
+ }
/**
=======================================
--- /trunk/www/errorreport.php Mon Nov 7 02:30:02 2011
+++ /trunk/www/errorreport.php Thu May 3 04:53:56 2012
@@ -17,19 +17,27 @@
$email = (string)$_REQUEST['email'];
$text = htmlspecialchars((string)$_REQUEST['text']);
-$session = SimpleSAML_Session::getInstance();
-$data = $session->getData('core:errorreport', $reportId);
+try {
+ $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) {
$data = array(
'exceptionMsg' => 'not set',
'exceptionTrace' => 'not set',
'reportId' => $reportId,
- 'trackId' => $session->getTrackId(),
+ 'trackId' => 'not set',
'url' => 'not set',
'version' => $config->getVersion(),
'referer' => 'not set',
);
+
+ if (isset($session)) {
+ $data['trackId'] = $session->getTrackId();
+ }
}
foreach ($data as $k => $v) {
--
You received this message because you are subscribed to the Google Groups
"simpleSAMLphp commits" group.
To post to this group, send email to simplesamlphp-commits@googlegroups.com.
To unsubscribe from this group, send email to
simplesamlphp-commits+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/simplesamlphp-commits?hl=en.