ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
sspmod_multiauth_Auth_Source_MultiAuth Class Reference
+ Inheritance diagram for sspmod_multiauth_Auth_Source_MultiAuth:
+ Collaboration diagram for sspmod_multiauth_Auth_Source_MultiAuth:

Public Member Functions

 __construct ($info, $config)
 Constructor for this authentication source. More...
 
 authenticate (&$state)
 Prompt the user with a list of authentication sources. More...
 
 logout (&$state)
 Log out from this authentication source. More...
 
 setPreviousSource ($source)
 Set the previous authentication source. More...
 
 getPreviousSource ()
 Get the previous authentication source. More...
 
- Public Member Functions inherited from SimpleSAML_Auth_Source
 __construct ($info, &$config)
 Constructor for an authentication source. More...
 
 getAuthId ()
 Retrieve the ID of this authentication source. More...
 
 authenticate (&$state)
 Process a request. More...
 
 reauthenticate (array &$state)
 Reauthenticate an user. More...
 
 initLogin ($return, $errorURL=null, array $params=array())
 Start authentication. More...
 
 logout (&$state)
 Log out from this authentication source. More...
 

Static Public Member Functions

static delegateAuthentication ($authId, $state)
 Delegate authentication. More...
 
- Static Public Member Functions inherited from SimpleSAML_Auth_Source
static getSourcesOfType ($type)
 Get sources of a specific type. More...
 
static completeAuth (&$state)
 Complete authentication. More...
 
static loginCompleted ($state)
 Called when a login operation has finished. More...
 
static completeLogout (&$state)
 Complete logout. More...
 
static getById ($authId, $type=null)
 Retrieve authentication source. More...
 
static logoutCallback ($state)
 Called when the authentication source receives an external logout request. More...
 
static getSources ()
 Retrieve list of authentication sources. More...
 

Data Fields

const AUTHID = 'sspmod_multiauth_Auth_Source_MultiAuth.AuthId'
 The key of the AuthId field in the state. More...
 
const STAGEID = 'sspmod_multiauth_Auth_Source_MultiAuth.StageId'
 The string used to identify our states. More...
 
const SOURCESID = 'sspmod_multiauth_Auth_Source_MultiAuth.SourceId'
 The key where the sources is saved in the state. More...
 
const SESSION_SOURCE = 'multiauth:selectedSource'
 The key where the selected source is saved in the session. More...
 

Private Attributes

 $sources
 Array of sources we let the user chooses among. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SimpleSAML_Auth_Source
 addLogoutCallback ($assoc, $state)
 Add a logout callback association. More...
 
 callLogoutCallback ($assoc)
 Call a logout callback based on association. More...
 
- Static Protected Member Functions inherited from SimpleSAML_Auth_Source
static validateSource ($source, $id)
 Make sure that the first element of an auth source is its identifier. More...
 
- Protected Attributes inherited from SimpleSAML_Auth_Source
 $authId
 

Detailed Description

Definition at line 11 of file MultiAuth.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_multiauth_Auth_Source_MultiAuth::__construct (   $info,
  $config 
)

Constructor for this authentication source.

Parameters
array$infoInformation about this authentication source.
array$configConfiguration.

Definition at line 44 of file MultiAuth.php.

References $config, $info, $source, $text, array, SimpleSAML_Configuration\getConfig(), and SimpleSAML_Configuration\getInstance().

44  {
45  assert('is_array($info)');
46  assert('is_array($config)');
47 
48  // Call the parent constructor first, as required by the interface
49  parent::__construct($info, $config);
50 
51  if (!array_key_exists('sources', $config)) {
52  throw new Exception('The required "sources" config option was not found');
53  }
54 
55  $globalConfiguration = SimpleSAML_Configuration::getInstance();
56  $defaultLanguage = $globalConfiguration->getString('language.default', 'en');
57  $authsources = SimpleSAML_Configuration::getConfig('authsources.php');
58  $this->sources = array();
59  foreach($config['sources'] as $source => $info) {
60 
61  if (is_int($source)) { // Backwards compatibility
62  $source = $info;
63  $info = array();
64  }
65 
66  if (array_key_exists('text', $info)) {
67  $text = $info['text'];
68  } else {
69  $text = array($defaultLanguage => $source);
70  }
71 
72  if (array_key_exists('css-class', $info)) {
73  $css_class = $info['css-class'];
74  } else {
75  // Use the authtype as the css class
76  $authconfig = $authsources->getArray($source, NULL);
77  if (!array_key_exists(0, $authconfig) || !is_string($authconfig[0])) {
78  $css_class = "";
79  } else {
80  $css_class = str_replace(":", "-", $authconfig[0]);
81  }
82  }
83 
84  $this->sources[] = array(
85  'source' => $source,
86  'text' => $text,
87  'css_class' => $css_class,
88  );
89  }
90  }
$text
Definition: errorreport.php:18
static getConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
Create styles array
The data for the language used.
$source
Definition: linkback.php:22
$info
Definition: index.php:5
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ Here is the call graph for this function:

Member Function Documentation

◆ authenticate()

sspmod_multiauth_Auth_Source_MultiAuth::authenticate ( $state)

Prompt the user with a list of authentication sources.

This method saves the information about the configured sources, and redirects to a page where the user must select one of these authentication sources.

This method never return. The authentication process is finished in the delegateAuthentication method.

Parameters
array&$stateInformation about the current authentication.

Definition at line 104 of file MultiAuth.php.

References $_GET, SimpleSAML_Auth_Source\$authId, $id, $params, $sources, $state, $url, array, SimpleSAML\Module\getModuleURL(), SimpleSAML\Utils\HTTP\redirectTrustedURL(), and SimpleSAML_Auth_State\saveState().

104  {
105  assert('is_array($state)');
106 
107  $state[self::AUTHID] = $this->authId;
108  $state[self::SOURCESID] = $this->sources;
109 
110  /* Save the $state array, so that we can restore if after a redirect */
111  $id = SimpleSAML_Auth_State::saveState($state, self::STAGEID);
112 
113  /* Redirect to the select source page. We include the identifier of the
114  saved state array as a parameter to the login form */
115  $url = SimpleSAML\Module::getModuleURL('multiauth/selectsource.php');
116  $params = array('AuthState' => $id);
117 
118  // Allowes the user to specify the auth souce to be used
119  if(isset($_GET['source'])) {
120  $params['source'] = $_GET['source'];
121  }
122 
124 
125  /* The previous function never returns, so this code is never
126  executed */
127  assert('FALSE');
128  }
$params
Definition: disable.php:11
$_GET["client_id"]
if(!array_key_exists('StateId', $_REQUEST)) $id
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
Definition: HTTP.php:962
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:303
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
Create styles array
The data for the language used.
$url
$sources
Array of sources we let the user chooses among.
Definition: MultiAuth.php:36
static saveState(&$state, $stage, $rawId=false)
Save the state.
Definition: State.php:194
+ Here is the call graph for this function:

◆ delegateAuthentication()

static sspmod_multiauth_Auth_Source_MultiAuth::delegateAuthentication (   $authId,
  $state 
)
static

Delegate authentication.

This method is called once the user has choosen one authentication source. It saves the selected authentication source in the session to be able to logout properly. Then it calls the authenticate method on such selected authentication source.

Parameters
string$authIdSelected authentication source
array$stateInformation about the current authentication.

Definition at line 141 of file MultiAuth.php.

References $as, SimpleSAML_Auth_Source\$authId, $session, $state, SimpleSAML_Auth_Source\completeAuth(), SimpleSAML_Session\DATA_TIMEOUT_SESSION_END, SimpleSAML_Auth_Source\getById(), SimpleSAML_Session\getSessionFromRequest(), and SimpleSAML_Auth_State\throwException().

141  {
142  assert('is_string($authId)');
143  assert('is_array($state)');
144 
146  $valid_sources = array_map(
147  function($src) {
148  return $src['source'];
149  },
150  $state[self::SOURCESID]
151  );
152  if ($as === NULL || !in_array($authId, $valid_sources, true)) {
153  throw new Exception('Invalid authentication source: ' . $authId);
154  }
155 
156  /* Save the selected authentication source for the logout process. */
158  $session->setData(self::SESSION_SOURCE, $state[self::AUTHID], $authId, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
159 
160  try {
161  $as->authenticate($state);
162  } catch (SimpleSAML_Error_Exception $e) {
164  } catch (Exception $e) {
167  }
169  }
static throwException($state, SimpleSAML_Error_Exception $exception)
Throw exception to the state exception handler.
Definition: State.php:343
$session
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
const DATA_TIMEOUT_SESSION_END
This is a timeout value for setData, which indicates that the data should never be deleted...
Definition: Session.php:26
$as
static completeAuth(&$state)
Complete authentication.
Definition: Source.php:135
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:324
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:243
+ Here is the call graph for this function:

◆ getPreviousSource()

sspmod_multiauth_Auth_Source_MultiAuth::getPreviousSource ( )

Get the previous authentication source.

This method retrieves the authentication source that the user selected last time or NULL if this is the first time or remembering is disabled.

Definition at line 226 of file MultiAuth.php.

References $_COOKIE, SimpleSAML_Auth_Source\$authId, and $cookieName.

226  {
227  $cookieName = 'multiauth_source_' . $this->authId;
228  if(array_key_exists($cookieName, $_COOKIE)) {
229  return $_COOKIE[$cookieName];
230  } else {
231  return NULL;
232  }
233  }
$_COOKIE['client_id']
Definition: server.php:9
$cookieName

◆ logout()

sspmod_multiauth_Auth_Source_MultiAuth::logout ( $state)

Log out from this authentication source.

This method retrieves the authentication source used for this session and then call the logout method on it.

Parameters
array&$stateInformation about the current logout operation.

Definition at line 179 of file MultiAuth.php.

References SimpleSAML_Auth_Source\$authId, $session, $source, $state, SimpleSAML_Auth_Source\getById(), and SimpleSAML_Session\getSessionFromRequest().

179  {
180  assert('is_array($state)');
181 
182  /* Get the source that was used to authenticate */
184  $authId = $session->getData(self::SESSION_SOURCE, $this->authId);
185 
187  if ($source === NULL) {
188  throw new Exception('Invalid authentication source during logout: ' . $source);
189  }
190  /* Then, do the logout on it */
191  $source->logout($state);
192  }
$session
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
$source
Definition: linkback.php:22
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:324
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:243
+ Here is the call graph for this function:

◆ setPreviousSource()

sspmod_multiauth_Auth_Source_MultiAuth::setPreviousSource (   $source)

Set the previous authentication source.

This method remembers the authentication source that the user selected by storing its name in a cookie.

Parameters
string$sourceName of the authentication source the user selected.

Definition at line 202 of file MultiAuth.php.

References SimpleSAML_Auth_Source\$authId, $config, $cookieName, $params, $source, array, SimpleSAML_Configuration\getInstance(), and SimpleSAML\Utils\HTTP\setCookie().

202  {
203  assert('is_string($source)');
204 
205  $cookieName = 'multiauth_source_' . $this->authId;
206 
208  $params = array(
209  /* We save the cookies for 90 days. */
210  'lifetime' => (60*60*24*90),
211  /* The base path for cookies.
212  This should be the installation directory for SimpleSAMLphp. */
213  'path' => $config->getBasePath(),
214  'httponly' => FALSE,
215  );
216 
218  }
$params
Definition: disable.php:11
$cookieName
static setCookie($name, $value, $params=null, $throw=true)
Set a cookie.
Definition: HTTP.php:1107
Create styles array
The data for the language used.
$source
Definition: linkback.php:22
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
+ Here is the call graph for this function:

Field Documentation

◆ $sources

sspmod_multiauth_Auth_Source_MultiAuth::$sources
private

Array of sources we let the user chooses among.

Definition at line 36 of file MultiAuth.php.

Referenced by authenticate().

◆ AUTHID

const sspmod_multiauth_Auth_Source_MultiAuth::AUTHID = 'sspmod_multiauth_Auth_Source_MultiAuth.AuthId'

The key of the AuthId field in the state.

Definition at line 16 of file MultiAuth.php.

◆ SESSION_SOURCE

const sspmod_multiauth_Auth_Source_MultiAuth::SESSION_SOURCE = 'multiauth:selectedSource'

The key where the selected source is saved in the session.

Definition at line 31 of file MultiAuth.php.

◆ SOURCESID

const sspmod_multiauth_Auth_Source_MultiAuth::SOURCESID = 'sspmod_multiauth_Auth_Source_MultiAuth.SourceId'

The key where the sources is saved in the state.

Definition at line 26 of file MultiAuth.php.

◆ STAGEID

const sspmod_multiauth_Auth_Source_MultiAuth::STAGEID = 'sspmod_multiauth_Auth_Source_MultiAuth.StageId'

The string used to identify our states.

Definition at line 21 of file MultiAuth.php.


The documentation for this class was generated from the following file: