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

SimpleSAML_Auth_Simple: Make requireAuth accept an array with options.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1767 44740490-163a-0410-bde0-09ae8108e29a
parent 318b57ce
No related branches found
No related tags found
No related merge requests found
...@@ -57,9 +57,9 @@ class SimpleSAML_Auth_Simple { ...@@ -57,9 +57,9 @@ class SimpleSAML_Auth_Simple {
* preserved. If $allowPost is FALSE, the user will be returned to the * preserved. If $allowPost is FALSE, the user will be returned to the
* current page with a GET request. * current page with a GET request.
* *
* @param bool $allowPost Whether POST requests will be preserved. The default is to preserve POST requests. * @param array $options Various options to the authentication request.
*/ */
public function requireAuth($allowPost = TRUE) { public function requireAuth(array $options = array()) {
assert('is_bool($allowPost)'); assert('is_bool($allowPost)');
$session = SimpleSAML_Session::getInstance(); $session = SimpleSAML_Session::getInstance();
...@@ -69,12 +69,23 @@ class SimpleSAML_Auth_Simple { ...@@ -69,12 +69,23 @@ class SimpleSAML_Auth_Simple {
return; return;
} }
$url = SimpleSAML_Utilities::selfURL(); if (array_key_exists('KeepPost', $options)) {
if ($allowPost && $_SERVER['REQUEST_METHOD'] === 'POST') { $keepPost = (bool)$options['KeepPost'];
$url = SimpleSAML_Utilities::createPostRedirectLink($url, $_POST); } else {
$keepPost = TRUE;
} }
SimpleSAML_Auth_Default::initLogin($this->authSource, $url); if (array_key_exists('ReturnTo', $options)) {
$returnTo = (string)$options['ReturnTo'];
} else {
$returnTo = SimpleSAML_Utilities::selfURL();
}
if ($keepPost && $_SERVER['REQUEST_METHOD'] === 'POST') {
$returnTo = SimpleSAML_Utilities::createPostRedirectLink($returnTo, $_POST);
}
SimpleSAML_Auth_Default::initLogin($this->authSource, $returnTo);
} }
......
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