37 assert(is_array(
$info));
40 assert(array_key_exists(
'AuthId',
$info));
41 $this->authId =
$info[
'AuthId'];
55 assert(is_string(
$type));
61 $sources =
$config->getOptions();
62 foreach ($sources as
$id) {
65 self::validateSource(
$source, $id);
116 assert(isset($state[
'ReturnCallback']));
121 foreach (
$data as $k => $v) {
139 assert(array_key_exists(
'LoginCompletedHandler',
$state));
143 $func =
$state[
'LoginCompletedHandler'];
144 assert(is_callable($func));
146 call_user_func($func,
$state);
166 assert(is_string($return) || is_array($return));
167 assert(is_string($errorURL) || $errorURL === null);
170 'SimpleSAML_Auth_Default.id' => $this->authId,
171 'SimpleSAML_Auth_Source.id' => $this->authId,
172 'SimpleSAML_Auth_Default.Return' => $return,
173 'SimpleSAML_Auth_Source.Return' => $return,
174 'SimpleSAML_Auth_Default.ErrorURL' => $errorURL,
175 'SimpleSAML_Auth_Source.ErrorURL' => $errorURL,
176 'LoginCompletedHandler' => array(get_class(),
'loginCompleted'),
177 'LogoutCallback' => array(get_class(),
'logoutCallback'),
178 'LogoutCallbackState' => array(
179 'SimpleSAML_Auth_Default.logoutSource' => $this->authId,
180 'SimpleSAML_Auth_Source.logoutSource' => $this->authId,
184 if (is_string($return)) {
185 $state[
'SimpleSAML_Auth_Default.ReturnURL'] = $return;
186 $state[
'SimpleSAML_Auth_Source.ReturnURL'] = $return;
189 if ($errorURL !== null) {
201 self::loginCompleted(
$state);
215 assert(array_key_exists(
'SimpleSAML_Auth_Source.Return',
$state));
216 assert(array_key_exists(
'SimpleSAML_Auth_Source.id',
$state));
217 assert(array_key_exists(
'Attributes',
$state));
218 assert(!array_key_exists(
'LogoutState',
$state) || is_array(
$state[
'LogoutState']));
220 $return =
$state[
'SimpleSAML_Auth_Source.Return'];
227 if (is_string($return)) {
230 call_user_func($return,
$state);
268 assert(array_key_exists(
'LogoutCompletedHandler',
$state));
272 $func =
$state[
'LogoutCompletedHandler'];
273 assert(is_callable($func));
275 call_user_func($func,
$state);
349 if ($authConfig === null) {
350 if (
$type !== null) {
352 'No authentication source with id '.
353 var_export(
$authId,
true).
' found.' 359 $ret = self::parseAuthSource(
$authId, $authConfig);
367 'Invalid type of authentication source '.
368 var_export(
$authId,
true).
'. Was '.var_export(get_class(
$ret),
true).
369 ', should be '.var_export($type,
true).
'.' 382 assert(array_key_exists(
'SimpleSAML_Auth_Source.logoutSource',
$state));
389 'Received logout from an invalid authentication source '.
413 assert(is_string($assoc));
416 if (!array_key_exists(
'LogoutCallback',
$state)) {
420 $callback =
$state[
'LogoutCallback'];
422 if (array_key_exists(
'LogoutCallbackState',
$state)) {
423 $callbackState =
$state[
'LogoutCallbackState'];
425 $callbackState = array();
428 $id = strlen($this->authId).
':'.$this->authId.$assoc;
431 'callback' => $callback,
432 'state' => $callbackState,
437 'SimpleSAML_Auth_Source.LogoutCallbacks',
457 assert(is_string($assoc));
459 $id = strlen($this->authId).
':'.$this->authId.$assoc;
464 if (
$data === null) {
471 assert(is_array(
$data));
472 assert(array_key_exists(
'callback',
$data));
473 assert(array_key_exists(
'state',
$data));
475 $callback =
$data[
'callback'];
476 $callbackState =
$data[
'state'];
478 $session->deleteData(
'SimpleSAML_Auth_Source.LogoutCallbacks',
$id);
479 call_user_func($callback, $callbackState);
508 'Invalid authentication source \''.
$id.
509 '\': First element must be
a string which identifies
the authentication source.
' const EXCEPTION_HANDLER_URL
The index in the state array which contains the exception handler URL.
logout(&$state)
Log out from this authentication source.
callLogoutCallback($assoc)
Call a logout callback based on association.
static throwException($state, SimpleSAML_Error_Exception $exception)
Throw exception to the state exception handler.
static loginCompleted($state)
Called when a login operation has finished.
if(!array_key_exists('StateId', $_REQUEST)) $id
getAuthId()
Retrieve the ID of this authentication source.
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
static completeLogout(&$state)
Complete logout.
authenticate(&$state)
Process a request.
static validateSource($source, $id)
Make sure that the first element of an auth source is its identifier.
static logoutCallback($state)
Called when the authentication source receives an external logout request.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
const DATA_TIMEOUT_SESSION_END
This is a timeout value for setData, which indicates that the data should never be deleted...
__construct($info, &$config)
Constructor for an authentication source.
addLogoutCallback($assoc, $state)
Add a logout callback association.
static getConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
static deleteState(&$state)
Delete state.
static getPersistentAuthData(array $state)
Get the persistent authentication state from the state array.
reauthenticate(array &$state)
Reauthenticate an user.
static getOptionalConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
static completeAuth(&$state)
Complete authentication.
static resolveClass($id, $type, $subclass=null)
Resolve module class.
static getSources()
Retrieve list of authentication sources.
initLogin($return, $errorURL=null, array $params=array())
Start authentication.
static getById($authId, $type=null)
Retrieve authentication source.
static getSessionFromRequest()
Retrieves the current session.
static getSourcesOfType($type)
Get sources of a specific type.