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

SimpleSAML_Auth_State: add session.state.timeout configuration option (issue 450).

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2978 44740490-163a-0410-bde0-09ae8108e29a
parent fa703094
No related branches found
No related tags found
No related merge requests found
...@@ -170,6 +170,11 @@ $config = array ( ...@@ -170,6 +170,11 @@ $config = array (
*/ */
'session.datastore.timeout' => (4*60*60), // 4 hours 'session.datastore.timeout' => (4*60*60), // 4 hours
/*
* Sets the duration, in seconds, auth state should be stored.
*/
'session.state.timeout' => (60*60), // 1 hour
/* /*
* Option to override the default settings for the session cookie name * Option to override the default settings for the session cookie name
*/ */
......
...@@ -79,6 +79,12 @@ class SimpleSAML_Auth_State { ...@@ -79,6 +79,12 @@ class SimpleSAML_Auth_State {
const EXCEPTION_PARAM = 'SimpleSAML_Auth_State_exceptionId'; const EXCEPTION_PARAM = 'SimpleSAML_Auth_State_exceptionId';
/**
* State timeout.
*/
private static $stateTimeout = NULL;
/** /**
* Retrieve the ID of a state array. * Retrieve the ID of a state array.
* *
...@@ -108,6 +114,21 @@ class SimpleSAML_Auth_State { ...@@ -108,6 +114,21 @@ class SimpleSAML_Auth_State {
} }
/**
* Retrieve state timeout.
*
* @return integer State timeout.
*/
private static function getStateTimeout() {
if (self::$stateTimeout === NULL) {
$globalConfig = SimpleSAML_Configuration::getInstance();
self::$stateTimeout = $globalConfig->getInteger('session.state.timeout', 60*60);
}
return self::$stateTimeout;
}
/** /**
* Save the state. * Save the state.
* *
...@@ -133,7 +154,7 @@ class SimpleSAML_Auth_State { ...@@ -133,7 +154,7 @@ class SimpleSAML_Auth_State {
/* Save state. */ /* Save state. */
$serializedState = serialize($state); $serializedState = serialize($state);
$session = SimpleSAML_Session::getInstance(); $session = SimpleSAML_Session::getInstance();
$session->setData('SimpleSAML_Auth_State', $id, $serializedState, 60*60); $session->setData('SimpleSAML_Auth_State', $id, $serializedState, self::getStateTimeout());
SimpleSAML_Logger::debug('Saved state: ' . var_export($return, TRUE)); SimpleSAML_Logger::debug('Saved state: ' . var_export($return, TRUE));
......
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