Skip to content
Snippets Groups Projects
Commit 527bfd8b authored by Olav Morken's avatar Olav Morken
Browse files

Auth_Default: Support function return.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2056 44740490-163a-0410-bde0-09ae8108e29a
parent 2d2feaa3
No related branches found
No related tags found
No related merge requests found
...@@ -19,20 +19,20 @@ class SimpleSAML_Auth_Default { ...@@ -19,20 +19,20 @@ class SimpleSAML_Auth_Default {
* This function never returns. * This function never returns.
* *
* @param string $authId The identifier of the authentication source. * @param string $authId The identifier of the authentication source.
* @param string $returnURL The URL we should direct the user to after authentication. * @param string|array $return The URL or function we should direct the user to after authentication.
* @param string|NULL $errorURL The URL we should direct the user to after failed authentication. * @param string|NULL $errorURL The URL we should direct the user to after failed authentication.
* Can be NULL, in which case a standard error page will be shown. * Can be NULL, in which case a standard error page will be shown.
* @param array $params Extra information about the login. Different authentication requestors may * @param array $params Extra information about the login. Different authentication requestors may
* provide different information. Optional, will default to an empty array. * provide different information. Optional, will default to an empty array.
*/ */
public static function initLogin($authId, $returnURL, $errorURL = NULL, array $params = array()) { public static function initLogin($authId, $return, $errorURL = NULL, array $params = array()) {
assert('is_string($authId)'); assert('is_string($authId)');
assert('is_string($returnURL)'); assert('is_string($return) || is_array($return)');
assert('is_string($errorURL) || is_null($errorURL)'); assert('is_string($errorURL) || is_null($errorURL)');
$state = array_merge($params, array( $state = array_merge($params, array(
'SimpleSAML_Auth_Default.id' => $authId, 'SimpleSAML_Auth_Default.id' => $authId,
'SimpleSAML_Auth_Default.ReturnURL' => $returnURL, 'SimpleSAML_Auth_Default.Return' => $return,
'SimpleSAML_Auth_Default.ErrorURL' => $errorURL, 'SimpleSAML_Auth_Default.ErrorURL' => $errorURL,
'LoginCompletedHandler' => array(get_class(), 'loginCompleted'), 'LoginCompletedHandler' => array(get_class(), 'loginCompleted'),
'LogoutCallback' => array(get_class(), 'logoutCallback'), 'LogoutCallback' => array(get_class(), 'logoutCallback'),
...@@ -41,6 +41,10 @@ class SimpleSAML_Auth_Default { ...@@ -41,6 +41,10 @@ class SimpleSAML_Auth_Default {
), ),
)); ));
if (is_string($return)) {
$state['SimpleSAML_Auth_Default.Return'] = $return;
}
if ($errorURL !== NULL) { if ($errorURL !== NULL) {
$state[SimpleSAML_Auth_State::EXCEPTION_HANDLER_URL] = $errorURL; $state[SimpleSAML_Auth_State::EXCEPTION_HANDLER_URL] = $errorURL;
} }
...@@ -69,12 +73,12 @@ class SimpleSAML_Auth_Default { ...@@ -69,12 +73,12 @@ class SimpleSAML_Auth_Default {
*/ */
public static function loginCompleted($state) { public static function loginCompleted($state) {
assert('is_array($state)'); assert('is_array($state)');
assert('array_key_exists("SimpleSAML_Auth_Default.ReturnURL", $state)'); assert('array_key_exists("SimpleSAML_Auth_Default.Return", $state)');
assert('array_key_exists("SimpleSAML_Auth_Default.id", $state)'); assert('array_key_exists("SimpleSAML_Auth_Default.id", $state)');
assert('array_key_exists("Attributes", $state)'); assert('array_key_exists("Attributes", $state)');
assert('!array_key_exists("LogoutState", $state) || is_array($state["LogoutState"])'); assert('!array_key_exists("LogoutState", $state) || is_array($state["LogoutState"])');
$returnURL = $state['SimpleSAML_Auth_Default.ReturnURL']; $return = $state['SimpleSAML_Auth_Default.Return'];
/* Save session state. */ /* Save session state. */
$session = SimpleSAML_Session::getInstance(); $session = SimpleSAML_Session::getInstance();
...@@ -94,8 +98,13 @@ class SimpleSAML_Auth_Default { ...@@ -94,8 +98,13 @@ class SimpleSAML_Auth_Default {
$session->setIdP(NULL); $session->setIdP(NULL);
} }
/* Redirect... */ if (is_string($return)) {
SimpleSAML_Utilities::redirect($returnURL); /* Redirect... */
SimpleSAML_Utilities::redirect($return);
} else {
call_user_func($return, $state);
assert('FALSE');
}
} }
......
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