public static function createPostRedirectLink($destination, $post) { return \SimpleSAML\Utils\HTTP::getPOSTRedirectURL($destination, $post); }
/** * Require the user to be authenticated. * * If the user is authenticated, this function returns immediately. * * If the user isn't authenticated, this function will authenticate the * user with the authentication source, and then return the user to the * current page. * * If $allowPost is set to TRUE, any POST data to the current page is * preserved. If $allowPost is FALSE, the user will be returned to the * current page with a GET request. * * @param array $options Various options to the authentication request. */ public function requireAuth(array $options = array()) { $session = SimpleSAML_Session::getInstance(); if ($session->isValid($this->authSource)) { /* Already authenticated. */ return; } if (array_key_exists('KeepPost', $options)) { $keepPost = (bool) $options['KeepPost']; } else { $keepPost = TRUE; } 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); } /* * An URL to restart the authentication, in case the user bookmarks * something, e.g. the discovery service page. */ $restartURL = $this->getLoginURL($returnTo); $hints = array(SimpleSAML_Auth_State::RESTART => $restartURL); SimpleSAML_Auth_Default::initLogin($this->authSource, $returnTo, NULL, $hints); }