Skip to content
Snippets Groups Projects
Commit 915b439e authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Reformat modules/core/www/authenticate.php, and remove misleading comment.

parent c3351506
No related branches found
No related tags found
No related merge requests found
<?php <?php
$config = SimpleSAML_Configuration::getInstance(); $config = SimpleSAML_Configuration::getInstance();
if (!array_key_exists('as', $_REQUEST)) { 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->data['sources'] = SimpleSAML_Auth_Source::getSources();
$t->show(); $t->show();
exit(); exit();
} }
$asId = (string) $_REQUEST['as'];
$asId = (string)$_REQUEST['as'];
$as = new SimpleSAML_Auth_Simple($asId); $as = new SimpleSAML_Auth_Simple($asId);
if(array_key_exists('logout', $_REQUEST)) { if (array_key_exists('logout', $_REQUEST)) {
$as->logout('/' . $config->getBaseURL() . 'logout.php'); $as->logout('/'.$config->getBaseURL().'logout.php');
} }
if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) { if (array_key_exists(SimpleSAML_Auth_State::EXCEPTION_PARAM, $_REQUEST)) {
// This is just a simple example of an error // This is just a simple example of an error
$state = SimpleSAML_Auth_State::loadExceptionState(); $state = SimpleSAML_Auth_State::loadExceptionState();
assert('array_key_exists(SimpleSAML_Auth_State::EXCEPTION_DATA, $state)'); assert('array_key_exists(SimpleSAML_Auth_State::EXCEPTION_DATA, $state)');
$e = $state[SimpleSAML_Auth_State::EXCEPTION_DATA]; $e = $state[SimpleSAML_Auth_State::EXCEPTION_DATA];
header('Content-Type: text/plain'); header('Content-Type: text/plain');
echo "Exception during login:\n"; echo "Exception during login:\n";
foreach ($e->format() as $line) { foreach ($e->format() as $line) {
echo $line . "\n"; echo $line."\n";
} }
exit(0); exit(0);
} }
if (!$as->isAuthenticated()) { if (!$as->isAuthenticated()) {
$url = SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId)); $url = SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $asId));
$params = array( $params = array(
'ErrorURL' => $url, 'ErrorURL' => $url,
'ReturnTo' => $url, 'ReturnTo' => $url,
); );
$as->login($params); $as->login($params);
} }
$attributes = $as->getAttributes(); $attributes = $as->getAttributes();
...@@ -51,8 +47,6 @@ $t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes'); ...@@ -51,8 +47,6 @@ $t = new SimpleSAML_XHTML_Template($config, 'status.php', 'attributes');
$t->data['header'] = '{status:header_saml20_sp}'; $t->data['header'] = '{status:header_saml20_sp}';
$t->data['attributes'] = $attributes; $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['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['logouturl'] = \SimpleSAML\Utils\HTTP::getSelfURLNoQuery() . '?as=' . urlencode($asId) . '&logout';
$t->show(); $t->show();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment