From 915b439e49234298f4bd7cd412fba201828fc7d2 Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Wed, 16 Mar 2016 13:08:01 +0100 Subject: [PATCH] Reformat modules/core/www/authenticate.php, and remove misleading comment. --- modules/core/www/authenticate.php | 60 ++++++++++++++----------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php index 8b52e786c..5b97da3db 100644 --- a/modules/core/www/authenticate.php +++ b/modules/core/www/authenticate.php @@ -1,48 +1,44 @@ <?php - - $config = SimpleSAML_Configuration::getInstance(); if (!array_key_exists('as', $_REQUEST)) { - $t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php'); + $t = new SimpleSAML_XHTML_Template($config, 'core:authsource_list.tpl.php'); - $t->data['sources'] = SimpleSAML_Auth_Source::getSources(); - $t->show(); - exit(); + $t->data['sources'] = SimpleSAML_Auth_Source::getSources(); + $t->show(); + exit(); } - -$asId = (string)$_REQUEST['as']; +$asId = (string) $_REQUEST['as']; $as = new SimpleSAML_Auth_Simple($asId); -if(array_key_exists('logout', $_REQUEST)) { - $as->logout('/' . $config->getBaseURL() . 'logout.php'); +if (array_key_exists('logout', $_REQUEST)) { + $as->logout('/'.$config->getBaseURL().'logout.php'); } if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) { - // This is just a simple example of an error - - $state = SimpleSAML_Auth_State::loadExceptionState(); - assert('array_key_exists(SimpleSAML_Auth_State::EXCEPTION_DATA, $state)'); - $e = $state[SimpleSAML_Auth_State::EXCEPTION_DATA]; - - header('Content-Type: text/plain'); - echo "Exception during login:\n"; - foreach ($e->format() as $line) { - echo $line . "\n"; - } - exit(0); + // This is just a simple example of an error + + $state = SimpleSAML_Auth_State::loadExceptionState(); + assert('array_key_exists(SimpleSAML_Auth_State::EXCEPTION_DATA, $state)'); + $e = $state[SimpleSAML_Auth_State::EXCEPTION_DATA]; + + header('Content-Type: text/plain'); + echo "Exception during login:\n"; + foreach ($e->format() as $line) { + echo $line."\n"; + } + exit(0); } - if (!$as->isAuthenticated()) { - $url = SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId)); - $params = array( - 'ErrorURL' => $url, - 'ReturnTo' => $url, - ); - $as->login($params); + $url = SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId)); + $params = array( + 'ErrorURL' => $url, + 'ReturnTo' => $url, + ); + $as->login($params); } $attributes = $as->getAttributes(); @@ -51,8 +47,6 @@ $t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes'); $t->data['header'] = '{status:header_saml20_sp}'; $t->data['attributes'] = $attributes; -// if saml:sp:IdP is set, this is SAML auth so we can pass a NameId -$t->data['nameid'] = !is_null( $as->getAuthData('saml:sp:NameID') ) ? $as->getAuthData('saml:sp:NameID') : FALSE; -$t->data['logouturl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery() . '?as=' . urlencode($asId) . '&logout'; +$t->data['nameid'] = !is_null($as->getAuthData('saml:sp:NameID')) ? $as->getAuthData('saml:sp:NameID') : false; +$t->data['logouturl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery().'?as='.urlencode($asId).'&logout'; $t->show(); - -- GitLab