ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
invalid_session.php
Go to the documentation of this file.
1<?php
2
12// retrieve the authentication state
13if (!array_key_exists('AuthState', $_REQUEST)) {
14 throw new SimpleSAML_Error_BadRequest('Missing mandatory parameter: AuthState');
15}
16
17try {
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
29if (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
40if (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();
56if (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'];
66if (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();
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static getById($authId, $type=null)
Retrieve authentication source.
Definition: Source.php:340
static throwException($state, SimpleSAML_Error_Exception $exception)
Throw exception to the state exception handler.
Definition: State.php:343
static loadState($id, $stage, $allowMissing=false)
Retrieve saved state.
Definition: State.php:259
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static getById($id)
Retrieve an IdP by ID.
Definition: IdP.php:124
$as
Attribute-related utility methods.
$idp
Definition: prp.php:13
$translator
$idpmdcfg
$template
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg