ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
invalid_session.php
Go to the documentation of this file.
1 <?php
2 
12 // retrieve the authentication state
13 if (!array_key_exists('AuthState', $_REQUEST)) {
14  throw new SimpleSAML_Error_BadRequest('Missing mandatory parameter: AuthState');
15 }
16 
17 try {
18  // try to get the state
19  $state = SimpleSAML_Auth_State::loadState($_REQUEST['AuthState'], 'saml:proxy:invalid_idp');
20 } catch (Exception $e) {
21  // the user probably hit the back button after starting the logout, try to recover the state with another stage
22  $state = SimpleSAML_Auth_State::loadState($_REQUEST['AuthState'], 'core:Logout:afterbridge');
23 
24  // success! Try to continue with reauthentication, since we no longer have a valid session here
25  $idp = SimpleSAML_IdP::getById($state['core:IdP']);
26  sspmod_saml_Auth_Source_SP::reauthPostLogout($idp, $state);
27 }
28 
29 if (isset($_POST['cancel'])) {
30  // the user does not want to logout, cancel login
32  $state,
33  new \SimpleSAML\Module\saml\Error\NoAvailableIDP(
34  \SAML2\Constants::STATUS_RESPONDER,
35  'User refused to reauthenticate with any of the IdPs requested.'
36  )
37  );
38 }
39 
40 if (isset($_POST['continue'])) {
41  // log the user out before being able to login again
42  $as = SimpleSAML_Auth_Source::getById($state['saml:sp:AuthId'], 'sspmod_saml_Auth_Source_SP');
44  $as->reauthLogout($state);
45 }
46 
48 $template = new SimpleSAML_XHTML_Template($cfg, 'saml:proxy/invalid_session.php');
49 $translator = $template->getTranslator();
50 $template->data['AuthState'] = (string)$_REQUEST['AuthState'];
51 
52 // get the name of the IdP
53 $idpmdcfg = $state['saml:sp:IdPMetadata'];
55 $idpmd = $idpmdcfg->toArray();
56 if (array_key_exists('name', $idpmd)) {
57  $template->data['idp_name'] = $translator->getPreferredTranslation($idpmd['name']);
58 } elseif (array_key_exists('OrganizationDisplayName', $idpmd)) {
59  $template->data['idp_name'] = $translator->getPreferredTranslation($idpmd['OrganizationDisplayName']);
60 } else {
61  $template->data['idp_name'] = $idpmd['entityid'];
62 }
63 
64 // get the name of the SP
65 $spmd = $state['SPMetadata'];
66 if (array_key_exists('name', $spmd)) {
67  $template->data['sp_name'] = $translator->getPreferredTranslation($spmd['name']);
68 } elseif (array_key_exists('OrganizationDisplayName', $spmd)) {
69  $template->data['sp_name'] = $translator->getPreferredTranslation($spmd['OrganizationDisplayName']);
70 } else {
71  $template->data['sp_name'] = $spmd['entityid'];
72 }
73 
74 $template->show();
Add rich text string
static getById($id)
Retrieve an IdP by ID.
Definition: IdP.php:131
static throwException($state, SimpleSAML_Error_Exception $exception)
Throw exception to the state exception handler.
Definition: State.php:343
$idpmdcfg
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
Attribute-related utility methods.
$translator
$as
catch(Exception $e) if(isset($_POST['cancel'])) if(isset($_POST['continue'])) $cfg
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
Definition: State.php:259
$idp
Definition: prp.php:13
$template
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:324
$_POST["username"]
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.