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

SimpleSAML_Auth_Simple: Add getLoginURL().

This patch adds a function to retrieve a login URL that can be used
to log the user in with the authentication source.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1851 44740490-163a-0410-bde0-09ae8108e29a
parent 492c0840
No related branches found
No related tags found
No related merge requests found
......@@ -137,6 +137,31 @@ class SimpleSAML_Auth_Simple {
return $session->getAttributes();
}
/**
* Retrieve an URL that can be used to log the user in.
*
* @param string|NULL $returnTo
* The page the user should be returned to afterwards. If this parameter
* is NULL, the user will be returned to the current page.
* @return string
* An URL which is suitable for use in link-elements.
*/
public function getLoginURL($returnTo = NULL) {
if ($returnTo === NULL) {
$returnTo = SimpleSAML_Utilities::selfURL();
}
$login = SimpleSAML_Module::getModuleURL('core/as_login.php');
$login = SimpleSAML_Utilities::addURLparameter($login, array(
'AuthId' => $this->authSource,
'ReturnTo' => $returnTo,
));
return $login;
}
}
?>
\ No newline at end of file
<?php
/**
* Endpoint for logging in with an authentication source.
*
* @package simpleSAMLphp
* @version $Id$
*/
if (!is_string($_REQUEST['ReturnTo'])) {
throw new SimpleSAML_Error_BadRequest('Missing ReturnTo parameter.');
}
if (!is_string($_REQUEST['AuthId'])) {
throw new SimpleSAML_Error_BadRequest('Missing AuthId parameter.');
}
$as = new SimpleSAML_Auth_Simple($_REQUEST['AuthId']);
$as->requireAuth(array(
'url' => $_REQUEST['ReturnTo'],
));
SimpleSAML_Utilities::redirect($_REQUEST['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