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

Auth_Simple: Extend to allow generic parameters to be passed to requireAuth.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1997 44740490-163a-0410-bde0-09ae8108e29a
parent 969271fe
No related branches found
No related tags found
No related merge requests found
...@@ -53,13 +53,16 @@ class SimpleSAML_Auth_Simple { ...@@ -53,13 +53,16 @@ class SimpleSAML_Auth_Simple {
* user with the authentication source, and then return the user to the * user with the authentication source, and then return the user to the
* current page. * current page.
* *
* If $allowPost is set to TRUE, any POST data to the current page is * This function accepts an array $params, which controls some parts of
* preserved. If $allowPost is FALSE, the user will be returned to the * the authentication. The accepted parameters depends on the authentication
* current page with a GET request. * source being used. Some parameters are generic:
* - 'KeepPost': If the current request is a POST request, keep the POST
* data until after the authentication.
* - 'ReturnTo': The URL the user should be returned to after authentication.
* *
* @param array $options Various options to the authentication request. * @param array $params Various options to the authentication request.
*/ */
public function requireAuth(array $options = array()) { public function requireAuth(array $params = array()) {
$session = SimpleSAML_Session::getInstance(); $session = SimpleSAML_Session::getInstance();
...@@ -68,14 +71,14 @@ class SimpleSAML_Auth_Simple { ...@@ -68,14 +71,14 @@ class SimpleSAML_Auth_Simple {
return; return;
} }
if (array_key_exists('KeepPost', $options)) { if (array_key_exists('KeepPost', $params)) {
$keepPost = (bool)$options['KeepPost']; $keepPost = (bool)$params['KeepPost'];
} else { } else {
$keepPost = TRUE; $keepPost = TRUE;
} }
if (array_key_exists('ReturnTo', $options)) { if (array_key_exists('ReturnTo', $params)) {
$returnTo = (string)$options['ReturnTo']; $returnTo = (string)$params['ReturnTo'];
} else { } else {
$returnTo = SimpleSAML_Utilities::selfURL(); $returnTo = SimpleSAML_Utilities::selfURL();
} }
...@@ -90,11 +93,9 @@ class SimpleSAML_Auth_Simple { ...@@ -90,11 +93,9 @@ class SimpleSAML_Auth_Simple {
*/ */
$restartURL = $this->getLoginURL($returnTo); $restartURL = $this->getLoginURL($returnTo);
$hints = array( $params[SimpleSAML_Auth_State::RESTART] = $restartURL;
SimpleSAML_Auth_State::RESTART => $restartURL,
);
SimpleSAML_Auth_Default::initLogin($this->authSource, $returnTo, NULL, $hints); SimpleSAML_Auth_Default::initLogin($this->authSource, $returnTo, NULL, $params);
} }
......
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