ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
authenticate.php
Go to the documentation of this file.
1 <?php
2 
4 
5 if (!array_key_exists('as', $_REQUEST)) {
6  $t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php');
7 
8  $t->data['sources'] = SimpleSAML_Auth_Source::getSources();
9  $t->show();
10  exit();
11 }
12 
13 $asId = (string) $_REQUEST['as'];
14 $as = new \SimpleSAML\Auth\Simple($asId);
15 
16 if (array_key_exists('logout', $_REQUEST)) {
17  $as->logout($config->getBasePath().'logout.php');
18 }
19 
20 if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) {
21  // This is just a simple example of an error
22 
24  assert(array_key_exists(SimpleSAML_Auth_State::EXCEPTION_DATA, $state));
26 
27  throw $e;
28 }
29 
30 if (!$as->isAuthenticated()) {
31  $url = SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId));
32  $params = array(
33  'ErrorURL' => $url,
34  'ReturnTo' => $url,
35  );
36  $as->login($params);
37 }
38 
39 $attributes = $as->getAttributes();
40 $authData = $as->getAuthDataArray();
41 
42 $t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes');
43 
44 $t->data['header'] = '{status:header_saml20_sp}';
45 $t->data['attributes'] = $attributes;
46 $t->data['authData'] = $authData;
47 $t->data['nameid'] = !is_null($as->getAuthData('saml:sp:NameID')) ? $as->getAuthData('saml:sp:NameID') : false;
48 $t->data['logouturl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery().'?as='.urlencode($asId).'&logout';
49 $t->show();
$config
Definition: authenticate.php:3
$as
if(array_key_exists('logout', $_REQUEST)) if(array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) if(! $as->isAuthenticated()) $attributes
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
Definition: Module.php:220
$authData
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
const EXCEPTION_PARAM
The URL parameter which contains the exception state id.
Definition: State.php:87
static getSelfURLNoQuery()
Retrieve the current URL using the base URL in the configuration, without the query parameters...
Definition: HTTP.php:843
exit
Definition: backend.php:16
const EXCEPTION_DATA
The index in the state array which contains the exception data.
Definition: State.php:75
$t
static loadExceptionState($id=null)
Retrieve an exception state.
Definition: State.php:380
$url
if(!array_key_exists('as', $_REQUEST)) $asId
static getSources()
Retrieve list of authentication sources.
Definition: Source.php:488
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.