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

SimpleSAML_Auth_Default: Add handleUnsolicedAuth().

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1783 44740490-163a-0410-bde0-09ae8108e29a
parent 931c8c01
No related branches found
No related tags found
No related merge requests found
......@@ -178,6 +178,44 @@ class SimpleSAML_Auth_Default {
$session->doLogout();
}
/**
* Handle a unsoliced login operations.
*
* This function creates a session from the received information. It
* will then redirect to the given URL.
*
* This is used to handle IdP initiated SSO.
*
* @param string $authId The id of the authentication source that received the request.
* @param array $state A state array.
* @param string $redirectTo The URL we should redirect the user to after
* updating the session.
*/
public static function handleUnsolicedAuth($authId, array $state, $redirectTo) {
assert('is_string($authId)');
assert('is_string($redirectTo)');
$session = SimpleSAML_Session::getInstance();
$session->doLogin($authId);
if (array_key_exists('Attributes', $state)) {
$session->setAttributes($state['Attributes']);
} else {
$session->setAttributes(array());
}
if(array_key_exists('Expires', $state)) {
$session->setSessionDuration($state['Expires'] - time());
}
if (array_key_exists('LogoutState', $state)) {
$session->setLogoutState($state['LogoutState']);
}
SimpleSAML_Utilities::redirect($redirectTo);
}
}
?>
\ No newline at end of file
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