From cfdf56ff1c9d456bc98e4388d824b93aacbf9834 Mon Sep 17 00:00:00 2001 From: Thijs Kinkhorst <thijs@kinkhorst.com> Date: Wed, 29 Apr 2020 18:44:08 +0000 Subject: [PATCH] core: remove frontpage_* pages and templates, replace with redirect These pages are now handled by the admin module. Add redirects to the new locations. --- modules/core/config/routes/routes.yaml | 24 --- modules/core/hooks/hook_frontpage.php | 37 ---- modules/core/routing/routes/routes.yml | 12 ++ modules/core/templates/_frontpage_menu.twig | 31 --- modules/core/templates/authsource_list.twig | 11 - modules/core/templates/frontpage_auth.twig | 18 -- modules/core/templates/frontpage_config.twig | 52 ----- .../core/templates/frontpage_federation.twig | 84 -------- modules/core/templates/frontpage_welcome.twig | 15 -- modules/core/www/authenticate.php | 53 ----- modules/core/www/frontpage_auth.php | 47 ----- modules/core/www/frontpage_config.php | 192 ------------------ modules/core/www/frontpage_federation.php | 156 -------------- modules/core/www/frontpage_welcome.php | 48 ----- modules/core/www/show_metadata.php | 39 ---- templates/hostnames.twig | 20 -- templates/index.twig | 33 --- templates/metadata-converter.twig | 60 ------ templates/metadata.twig | 62 ------ tests/www/IndexTest.php | 6 +- 20 files changed, 15 insertions(+), 985 deletions(-) delete mode 100644 modules/core/config/routes/routes.yaml delete mode 100644 modules/core/hooks/hook_frontpage.php delete mode 100644 modules/core/templates/_frontpage_menu.twig delete mode 100644 modules/core/templates/authsource_list.twig delete mode 100644 modules/core/templates/frontpage_auth.twig delete mode 100644 modules/core/templates/frontpage_config.twig delete mode 100644 modules/core/templates/frontpage_federation.twig delete mode 100644 modules/core/templates/frontpage_welcome.twig delete mode 100644 modules/core/www/authenticate.php delete mode 100644 modules/core/www/frontpage_auth.php delete mode 100644 modules/core/www/frontpage_config.php delete mode 100644 modules/core/www/frontpage_federation.php delete mode 100644 modules/core/www/frontpage_welcome.php delete mode 100644 modules/core/www/show_metadata.php delete mode 100644 templates/hostnames.twig delete mode 100644 templates/index.twig delete mode 100644 templates/metadata-converter.twig delete mode 100644 templates/metadata.twig diff --git a/modules/core/config/routes/routes.yaml b/modules/core/config/routes/routes.yaml deleted file mode 100644 index 12884b024..000000000 --- a/modules/core/config/routes/routes.yaml +++ /dev/null @@ -1,24 +0,0 @@ -core-account: - path: /account/{as} - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Login:account' } -core-account-disco-clearchoices: - path: /account/disco/clearchoices - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Login:cleardiscochoices' } -core-login: - path: /login/{as} - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Login:login', as: null } -core-logout: - path: /logout/{as} - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Login:logout' } -core-error-nocookie: - path: /error/nocookie - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Exception:nocookie' } -core-cardinality: - path: /error/cardinality - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Exception:cardinality' } -core-warning-shortssointerval: - path: /warning/short_sso_interval - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Exception:shortSsoInterval' } -core-post-redirect: - path: /postredirect - defaults: { _controller: 'SimpleSAML\Module\core\Controller\Redirection:postredirect' } diff --git a/modules/core/hooks/hook_frontpage.php b/modules/core/hooks/hook_frontpage.php deleted file mode 100644 index 8eb6d6416..000000000 --- a/modules/core/hooks/hook_frontpage.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -declare(strict_types=1); - -use Webmozart\Assert\Assert; - -/** - * Hook to add the modinfo module to the frontpage. - * - * @param array &$links The links on the frontpage, split into sections. - * @return void - */ -function core_hook_frontpage(array &$links): void -{ - Assert::keyExists($links, 'links'); - - $links['links']['frontpage_welcome'] = [ - 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_welcome.php'), - 'text' => '{core:frontpage:welcome}', - 'shorttext' => '{core:frontpage:welcome}', - ]; - $links['links']['frontpage_config'] = [ - 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_config.php'), - 'text' => '{core:frontpage:configuration}', - 'shorttext' => '{core:frontpage:configuration}', - ]; - $links['links']['frontpage_auth'] = [ - 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_auth.php'), - 'text' => '{core:frontpage:auth}', - 'shorttext' => '{core:frontpage:auth}', - ]; - $links['links']['frontpage_federation'] = [ - 'href' => SimpleSAML\Module::getModuleURL('core/frontpage_federation.php'), - 'text' => '{core:frontpage:federation}', - 'shorttext' => '{core:frontpage:federation}', - ]; -} diff --git a/modules/core/routing/routes/routes.yml b/modules/core/routing/routes/routes.yml index 12884b024..83e5e6ff3 100644 --- a/modules/core/routing/routes/routes.yml +++ b/modules/core/routing/routes/routes.yml @@ -22,3 +22,15 @@ core-warning-shortssointerval: core-post-redirect: path: /postredirect defaults: { _controller: 'SimpleSAML\Module\core\Controller\Redirection:postredirect' } +core-legacy-welcome: + path: /frontpage_welcome.php + defaults: { _controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', path: /admin/, permanent: true } +core-legacy-config: + path: /frontpage_config.php + defaults: { _controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', path: /admin/, permanent: true } +core-legacy-auth: + path: /frontpage_auth.php + defaults: { _controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', path: /admin/test, permanent: true } +core-legacy-federation: + path: /frontpage_federation.php + defaults: { _controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', path: /admin/federation, permanent: true } diff --git a/modules/core/templates/_frontpage_menu.twig b/modules/core/templates/_frontpage_menu.twig deleted file mode 100644 index 3af633752..000000000 --- a/modules/core/templates/_frontpage_menu.twig +++ /dev/null @@ -1,31 +0,0 @@ -<div class="pure-g frontpage-menu"> - <div class="pure-u-2-3"> - <div class="pure-menu pure-menu-horizontal"> - <ul class="pure-menu-list"> - <li class="pure-menu-item{% if frontpage_section == "welcome" %} pure-menu-selected{% endif %}"> - <a href="frontpage_welcome.php" class="pure-menu-link">Welcome</a> - </li> - <li class="pure-menu-item{% if frontpage_section == "config" %} pure-menu-selected{% endif %}"> - <a href="frontpage_config.php" class="pure-menu-link">Configuration</a> - </li> - <li class="pure-menu-item{% if frontpage_section == "auth" %} pure-menu-selected{% endif %}"> - <a href="frontpage_auth.php" class="pure-menu-link">Authentication</a> - </li> - <li class="pure-menu-item{% if frontpage_section == "federation" %} pure-menu-selected{% endif %}"> - <a href="frontpage_federation.php" class="pure-menu-link">Federation</a> - </li> - </ul> - </div> - </div> - <div class="pure-u-1-3"> - {% if isadmin %} - <p class="float-r youareadmin">{{ '{core:frontpage:loggedin_as_admin}'|trans }} - <a href="{{ logouturl }}"><i class="fa fa-sign-out" title="{{ '{core:frontpage:logout}'|trans }}"></i></a> - </p> - {% else %} - <p class="float-r youareadmin"> - <a href="{{ loginurl }}">{{ '{core:frontpage:login_as_admin}'|trans }}</a> - </p> - {% endif %} - </div> -</div> diff --git a/modules/core/templates/authsource_list.twig b/modules/core/templates/authsource_list.twig deleted file mode 100644 index f653ad138..000000000 --- a/modules/core/templates/authsource_list.twig +++ /dev/null @@ -1,11 +0,0 @@ -{% set pagetitle = 'Test Authentication Sources'|trans %} -{% extends "base.twig" %} - -{% block content %} - <h2>{{ pagetitle }} </h2> - <ul> - {% for key, name in sources %} - <li><a href="{{ moduleURL('core/login/' ~ name|escape('url')) }}">{{ name }}</a></li> - {% endfor %} - </ul> -{% endblock %} diff --git a/modules/core/templates/frontpage_auth.twig b/modules/core/templates/frontpage_auth.twig deleted file mode 100644 index cfe3c4f9d..000000000 --- a/modules/core/templates/frontpage_auth.twig +++ /dev/null @@ -1,18 +0,0 @@ -{% set pagetitle = '{core:frontpage:page_title}'|trans %} -{% set frontpage_section = 'auth' %} -{% extends "base.twig" %} - -{% block content %} - {% include "@core/_frontpage_menu.twig" %} - - <ul> - {% for key, link in links_auth %} - <li> - <a href="{{ link.href }}">{{ link.text|trans|escape('html') }}</a> - {% if link.deprecated is defined and link.deprecated is not empty %} - <strong>{{ '{core:frontpage:deprecated}'|trans }}</strong> - {% endif %} - </li> - {% endfor %} - </ul> -{% endblock %} diff --git a/modules/core/templates/frontpage_config.twig b/modules/core/templates/frontpage_config.twig deleted file mode 100644 index bdfe93574..000000000 --- a/modules/core/templates/frontpage_config.twig +++ /dev/null @@ -1,52 +0,0 @@ -{% set pagetitle = '{core:frontpage:page_title}'|trans %} -{% set frontpage_section = 'config' %} -{% extends "base.twig" %} - -{% block content %} - {% include "@core/_frontpage_menu.twig" %} - - <div> - <code class="simplesaml_version">{{ directory }} ({{ version }})</code> - </div> - - {% set icon_enabled = '<i class="fa fa-check"></i>' %} - {% set icon_disabled = '<i class="fa fa-ban"></i>' %} - - <div class="enablebox mini"> - <table> - <tr class="{%- if enablematrix.saml20idp %}enabled{% else %}disabled{% endif -%}"> - <td>SAML 2.0 IdP</td> - <td>{%- if enablematrix.saml20idp %}{{ icon_enabled|raw }}{% else %}{{ icon_disabled|raw }}{% endif -%}</td> - </tr> - </table> - </div> - - <h2>{{ '{core:frontpage:configuration}'|trans }}</h2> - <ul> - {% for key, link in links_config %} - <li><a href="{{ link.href|escape('html') }}">{{ link.text|trans|escape('html') }}</a></li> - {% endfor %} - </ul> - - {% if warnings is defined and warnings is not empty %} - <h2>{{ '{core:frontpage:warnings}'|trans|escape('html') }}</h2> - {% for key, warning in warnings %} - <div class="caution">{{ warning|trans|raw }}</div> - {% endfor %} - {% endif %} - - {% if isadmin %} - <h2>{{ '{core:frontpage:checkphp}'|trans }}</h2> - <div class="enablebox"> - <table> - {% for key, func in funcmatrix %} - <tr class="{%- if func.enabled %}enabled{% else %}disabled{% endif -%}"> - <td>{%- if func.enabled %}{{ icon_enabled|raw }}{% else %}{{ icon_disabled|raw }}{% endif -%}</td> - <td>{{ requiredmap[func.required]|trans }}</td> - <td>{{ func.descr }}</td> - </tr> - {% endfor %} - </table> - </div> - {% endif %} -{% endblock %} diff --git a/modules/core/templates/frontpage_federation.twig b/modules/core/templates/frontpage_federation.twig deleted file mode 100644 index 68642316b..000000000 --- a/modules/core/templates/frontpage_federation.twig +++ /dev/null @@ -1,84 +0,0 @@ -{% set pagetitle = '{core:frontpage:page_title}'|trans %} -{% set frontpage_section = 'federation' %} -{% extends "base.twig" %} - -{% block content %} - {% include "@core/_frontpage_menu.twig" %} - - {% if metaentries.hosted is iterable and metaentries.hosted is not empty %} - <h2>{% trans %}Hosted entities{% endtrans %}</h2> - <dl> - {% for key, set in metaentries.hosted %} - {% set metadataset = attribute(set, 'metadata-set') %} - <dt>{{ mtype[metadataset]|trans }}</dt> - <dd> - <p>Entity ID: <code>{{ set.entityid }}</code> - {% if set.deprecated is defined and set.deprecated %} - <br /><span class="entity-deprecated">Deprecated</span> - {% endif %} - {% if set.entityid != attribute(set, 'metadata-index') %} - <br />Index: {{ attribute(set, 'metadata-index') }} - {% endif %} - {% if set.name_translated is defined %} - <br /><span class="entity-name">{{ set.name_translated }}</span> - {% endif %} - {% if set.descr_translated is defined %} - <br /><span class="entity-name">{{ set.descr_translated }}</span> - {% endif %} - <br />[ <a href="{{ attribute(set, 'metadata-url') }}">{{'{core:frontpage:show_metadata}'|trans }}</a> ] - </p> - </dd> - {% endfor %} - </dl> - {% endif %} - - {% if metaentries.remote is iterable and metaentries.remote is not empty %} - <h2>{% trans %}Trusted entities{% endtrans %}</h2> - {% for key, set in metaentries.remote %} - <fieldset class="fancyfieldset"> - <legend>{{ mtype[key]|trans }} (Trusted)</legend> - <ul> - {% for entityid, entity in set %} - <li><a href="{{ (metadata_url ~ '?entityid=' ~ entity.entityid ~ '&set=' ~ key)|escape('html') }}"> - {%- if entity.name_translated is defined %} - {{ entity.name_translated }} - {% elseif entity.organizationdisplayname_translated is defined %} - {{ entity.organizationdisplayname_translated }} - {% else %}{{ entity.entityid|escape('html') }} - {% endif -%}</a> - - {%- if entity.expire is defined %} - {% if entity.expire > date().timestamp %} - <span class="entity-expired"> (expired {{ ((date().timestamp - entity.expire) / 3600) }} hours ago)</span> - {% else %} (expires in {{ ((entity.expire - date().timestamp) / 3600) }} hours){% endif -%}{% endif %} - </li> - {% endfor %} - </ul> - </fieldset> - {% endfor %} - {% endif %} - - <h2>{{ '{core:frontpage:tools}'|trans }}</h2> - <ul> - {% for key, link in links_federation %} - <li><a href="{{ link.href|escape('html') }}">{{ link.text|trans|escape('html') }}</a></li> - {% endfor %} - </ul> - - {% if isadmin %} - <form action="{{ metadata_url }}" method="get" class="pure-form"> - <p>Look up metadata for entity: - <select name="set"> - {% if metaentries.remote is defined and metaentries.remote is not empty %} - {% for key, set in metaentries.remote %} - <option value="{{ key|escape('html') }}">{{ mtype[key]|trans }}</option> - {% endfor %} - {% endif %} - </select> - <input type="text" name="entityid" class="edge"> - <button class="pure-button pure-button-red" type="submit">Lookup</button> - </p> - </form> - </fieldset> - {% endif %} -{% endblock %} diff --git a/modules/core/templates/frontpage_welcome.twig b/modules/core/templates/frontpage_welcome.twig deleted file mode 100644 index 653c54935..000000000 --- a/modules/core/templates/frontpage_welcome.twig +++ /dev/null @@ -1,15 +0,0 @@ -{% set pagetitle = '{core:frontpage:page_title}'|trans %} -{% set frontpage_section = 'welcome' %} -{% extends "base.twig" %} - -{% block content %} - {% include "@core/_frontpage_menu.twig" %} - - <p>{{ '{core:frontpage:intro}'|trans|raw }}</p> - <ul> - {% for key, link in links_welcome %} - <li><a href="{{ link.href|escape('html') }}">{{ link.text|trans|escape('html') }}</a></li> - {% endfor %} - </ul> - -{% endblock %} diff --git a/modules/core/www/authenticate.php b/modules/core/www/authenticate.php deleted file mode 100644 index d46da93e3..000000000 --- a/modules/core/www/authenticate.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -use Webmozart\Assert\Assert; - -$config = \SimpleSAML\Configuration::getInstance(); - -if (!array_key_exists('as', $_REQUEST)) { - $t = new \SimpleSAML\XHTML\Template($config, 'core:authsource_list.twig'); - - $t->data['sources'] = \SimpleSAML\Auth\Source::getSources(); - $t->send(); - exit(); -} - -$asId = (string) $_REQUEST['as']; -$as = new \SimpleSAML\Auth\Simple($asId); - -if (array_key_exists('logout', $_REQUEST)) { - $as->logout($config->getBasePath() . 'logout.php'); -} - -if (array_key_exists(\SimpleSAML\Auth\State::EXCEPTION_PARAM, $_REQUEST)) { - // This is just a simple example of an error - - /** @var array $state */ - $state = \SimpleSAML\Auth\State::loadExceptionState(); - - Assert::keyExists($state, \SimpleSAML\Auth\State::EXCEPTION_DATA); - - $e = $state[\SimpleSAML\Auth\State::EXCEPTION_DATA]; - throw $e; -} - -if (!$as->isAuthenticated()) { - $url = \SimpleSAML\Module::getModuleURL('core/authenticate.php', ['as' => $asId]); - $params = [ - 'ErrorURL' => $url, - 'ReturnTo' => $url, - ]; - $as->login($params); -} - -$attributes = $as->getAttributes(); -$authData = $as->getAuthDataArray(); - -$t = new \SimpleSAML\XHTML\Template($config, 'status.php', 'attributes'); - -$t->data['header'] = '{status:header_saml20_sp}'; -$t->data['attributes'] = $attributes; -$t->data['authData'] = $authData; -$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->send(); diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php deleted file mode 100644 index 3d2a31a7b..000000000 --- a/modules/core/www/frontpage_auth.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -// Load SimpleSAMLphp configuration -$config = \SimpleSAML\Configuration::getInstance(); -$session = \SimpleSAML\Session::getSessionFromRequest(); - -// Check if valid local session exists -if ($config->getBoolean('admin.protectindexpage', false)) { - \SimpleSAML\Utils\Auth::requireAdmin(); -} -$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); -$isadmin = \SimpleSAML\Utils\Auth::isAdmin(); -$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); - -$links = []; -$links_welcome = []; -$links_config = []; -$links_auth = []; -$links_federation = []; - -$links_auth[] = [ - 'href' => 'authenticate.php', - 'text' => '{core:frontpage:authtest}', -]; - -$allLinks = [ - 'links' => &$links, - 'welcome' => &$links_welcome, - 'config' => &$links_config, - 'auth' => &$links_auth, - 'federation' => &$links_federation, -]; -\SimpleSAML\Module::callHooks('frontpage', $allLinks); - -$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_auth.twig'); -$t->data['pageid'] = 'frontpage_auth'; -$t->data['isadmin'] = $isadmin; -$t->data['loginurl'] = $loginurl; -$t->data['logouturl'] = $logouturl; - -$t->data['links'] = $links; -$t->data['links_welcome'] = $links_welcome; -$t->data['links_config'] = $links_config; -$t->data['links_auth'] = $links_auth; -$t->data['links_federation'] = $links_federation; - -$t->send(); diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php deleted file mode 100644 index d53256465..000000000 --- a/modules/core/www/frontpage_config.php +++ /dev/null @@ -1,192 +0,0 @@ -<?php - -// Load SimpleSAMLphp configuration -$config = \SimpleSAML\Configuration::getInstance(); -$session = \SimpleSAML\Session::getSessionFromRequest(); - -// Check if valid local session exists. -if ($config->getBoolean('admin.protectindexpage', false)) { - \SimpleSAML\Utils\Auth::requireAdmin(); -} -$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); -$isadmin = \SimpleSAML\Utils\Auth::isAdmin(); -$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); - -$warnings = []; - -if (!\SimpleSAML\Utils\HTTP::isHTTPS()) { - $warnings[] = '{core:frontpage:warnings_https}'; -} - -if ($config->getValue('secretsalt') === 'defaultsecretsalt') { - $warnings[] = '{core:frontpage:warnings_secretsalt}'; -} - -if (extension_loaded('suhosin')) { - $suhosinLength = ini_get('suhosin.get.max_value_length'); - if (empty($suhosinLength) || (int) $suhosinLength < 2048) { - $warnings[] = '{core:frontpage:warnings_suhosin_url_length}'; - } -} - -$links = []; -$links_welcome = []; -$links_config = []; -$links_auth = []; -$links_federation = []; - -$links_config[] = [ - 'href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/hostnames.php', - 'text' => '{core:frontpage:link_diagnostics}' -]; - -$links_config[] = [ - 'href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/phpinfo.php', - 'text' => '{core:frontpage:link_phpinfo}' -]; - -$allLinks = [ - 'links' => &$links, - 'welcome' => &$links_welcome, - 'config' => &$links_config, - 'auth' => &$links_auth, - 'federation' => &$links_federation, -]; -\SimpleSAML\Module::callHooks('frontpage', $allLinks); -\SimpleSAML\Logger::debug('The "frontpage" hook has been deprecated for the configuration page. Implement the ' . - '"configpage" hook instead.'); - -// Check for updates. Store the remote result in the session so we -// don't need to fetch it on every access to this page. -$current = $config->getVersion(); -if ($config->getBoolean('admin.checkforupdates', true) && $current !== 'master') { - if (!function_exists('curl_init')) { - $warnings[] = '{core:frontpage:warnings_curlmissing}'; - } else { - $latest = $session->getData("core:latest_simplesamlphp_version", "version"); - - if (!$latest) { - $api_url = 'https://api.github.com/repos/simplesamlphp/simplesamlphp/releases'; - $ch = curl_init($api_url . '/latest'); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_USERAGENT, 'SimpleSAMLphp'); - curl_setopt($ch, CURLOPT_TIMEOUT, 2); - curl_setopt($ch, CURLOPT_PROXY, $config->getString('proxy', null)); - curl_setopt($ch, CURLOPT_PROXYUSERPWD, $config->getValue('proxy.auth', null)); - $response = curl_exec($ch); - - if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) === 200) { - /** @psalm-suppress InvalidScalarArgument */ - $latest = json_decode(strval($response), true); - $session->setData("core:latest_simplesamlphp_version", "version", $latest); - } - curl_close($ch); - } - - if ($latest && version_compare($current, ltrim($latest['tag_name'], 'v'), 'lt')) { - $outdated = true; - $warnings[] = '{core:frontpage:warnings_outdated}'; - } - } -} - -$enablematrix = [ - 'saml20idp' => $config->getBoolean('enable.saml20-idp', false), -]; - - -$functionchecks = [ - 'time' => ['required', 'Date/Time Extension'], - 'hash' => ['required', 'Hashing function'], - 'gzinflate' => ['required', 'ZLib'], - 'openssl_sign' => ['required', 'OpenSSL'], - 'dom_import_simplexml' => ['required', 'XML DOM'], - 'preg_match' => ['required', 'RegEx support'], - 'json_decode' => ['required', 'JSON support'], - 'class_implements' => ['required', 'Standard PHP Library (SPL)'], - 'mb_strlen' => ['required', 'Multibyte String Extension'], - 'curl_init' => ['optional', 'cURL (required if automatic version checks are used, also by some modules.'], - 'session_start' => ['optional', 'Session Extension (required if PHP sessions are used)'], - 'pdo_drivers' => ['optional', 'PDO Extension (required if a database backend is used)'], -]; -if (\SimpleSAML\Module::isModuleEnabled('ldap')) { - $functionchecks['ldap_bind'] = ['optional', 'LDAP Extension (required if an LDAP backend is used)']; -} -if (\SimpleSAML\Module::isModuleEnabled('radius')) { - $functionchecks['radius_auth_open'] = ['optional', 'Radius Extension (required if a Radius backend is used)']; -} - -$funcmatrix = []; -$funcmatrix[] = [ - 'required' => 'required', - 'descr' => 'PHP Version >= 7.2. You run: ' . phpversion(), - 'enabled' => version_compare(phpversion(), '7.2', '>=') -]; -foreach ($functionchecks as $func => $descr) { - $funcmatrix[] = ['descr' => $descr[1], 'required' => $descr[0], 'enabled' => function_exists($func)]; -} - -$funcmatrix[] = [ - 'required' => 'optional', - 'descr' => 'predis/predis (required if the redis data store is used)', - 'enabled' => class_exists('\Predis\Client'), -]; - -$funcmatrix[] = [ - 'required' => 'optional', - 'descr' => 'Memcache or Memcached Extension (required if a Memcached backend is used)', - 'enabled' => class_exists('Memcache') || class_exists('Memcached'), -]; - -// Some basic configuration checks - -if ($config->getString('technicalcontact_email', 'na@example.org') === 'na@example.org') { - $mail_ok = false; -} else { - $mail_ok = true; -} -$funcmatrix[] = [ - 'required' => 'recommended', - 'descr' => 'technicalcontact_email option set', - 'enabled' => $mail_ok -]; -if ($config->getString('auth.adminpassword', '123') === '123') { - $password_ok = false; -} else { - $password_ok = true; -} -$funcmatrix[] = [ - 'required' => 'required', - 'descr' => 'auth.adminpassword option set', - 'enabled' => $password_ok -]; - -$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_config.twig'); -$translator = $t->getTranslator(); -$t->data['pageid'] = 'frontpage_config'; -$t->data['header'] = '{core:frontpage:page_title}'; -$t->data['isadmin'] = $isadmin; -$t->data['loginurl'] = $loginurl; -$t->data['logouturl'] = $logouturl; - -$t->data['warnings'] = $warnings; - - -$t->data['links'] = $links; -$t->data['links_welcome'] = $links_welcome; -$t->data['links_config'] = $links_config; -$t->data['links_auth'] = $links_auth; -$t->data['links_federation'] = $links_federation; - - -$t->data['enablematrix'] = $enablematrix; -$t->data['funcmatrix'] = $funcmatrix; -$t->data['requiredmap'] = [ - 'recommended' => $translator->noop('{core:frontpage:recommended}'), - 'required' => $translator->noop('{core:frontpage:required}'), - 'optional' => $translator->noop('{core:frontpage:optional}'), -]; -$t->data['version'] = $config->getVersion(); -$t->data['directory'] = dirname(dirname(dirname(dirname(__FILE__)))); - -$t->send(); diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php deleted file mode 100644 index 5d683cc17..000000000 --- a/modules/core/www/frontpage_federation.php +++ /dev/null @@ -1,156 +0,0 @@ -<?php - -// Load SimpleSAMLphp configuration -$config = \SimpleSAML\Configuration::getInstance(); -$session = \SimpleSAML\Session::getSessionFromRequest(); - -// Check if valid local session exists. -if ($config->getBoolean('admin.protectindexpage', false)) { - \SimpleSAML\Utils\Auth::requireAdmin(); -} -$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); -$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); -$isadmin = \SimpleSAML\Utils\Auth::isAdmin(); - -$links = []; -$links_welcome = []; -$links_config = []; -$links_auth = []; -$links_federation = []; - -if ($config->getBoolean('idpdisco.enableremember', false)) { - $links_federation[] = [ - 'href' => 'cleardiscochoices.php', - 'text' => '{core:frontpage:link_cleardiscochoices}', - ]; -} - - -$links_federation[] = [ - 'href' => \SimpleSAML\Utils\HTTP::getBaseURL() . 'admin/metadata-converter.php', - 'text' => '{core:frontpage:link_xmlconvert}', -]; - -$allLinks = [ - 'links' => &$links, - 'welcome' => &$links_welcome, - 'config' => &$links_config, - 'auth' => &$links_auth, - 'federation' => &$links_federation, -]; -\SimpleSAML\Module::callHooks('frontpage', $allLinks); - - -$metadataHosted = []; -\SimpleSAML\Module::callHooks('metadata_hosted', $metadataHosted); - -$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); - -$metaentries = ['hosted' => $metadataHosted, 'remote' => []]; - - -if ($isadmin) { - $metaentries['remote']['saml20-idp-remote'] = $metadata->getList('saml20-idp-remote', true); -} - -if ($config->getBoolean('enable.saml20-idp', false) === true) { - try { - $metaentries['hosted']['saml20-idp'] = $metadata->getMetaDataCurrent('saml20-idp-hosted'); - $metaentries['hosted']['saml20-idp']['metadata-url'] = - $config->getBasePath() . 'saml2/idp/metadata.php?output=xhtml'; - if ($isadmin) { - $metaentries['remote']['saml20-sp-remote'] = $metadata->getList('saml20-sp-remote', true); - } - } catch (Exception $e) { - \SimpleSAML\Logger::error('Federation: Error loading saml20-idp: ' . $e->getMessage()); - } -} -if ($config->getBoolean('enable.adfs-idp', false) === true) { - try { - $metaentries['hosted']['adfs-idp'] = $metadata->getMetaDataCurrent('adfs-idp-hosted'); - $metaentries['hosted']['adfs-idp']['metadata-url'] = \SimpleSAML\Module::getModuleURL( - 'adfs/idp/metadata.php', - ['output' => 'xhtml'] - ); - if ($isadmin) { - $metaentries['remote']['adfs-sp-remote'] = $metadata->getList('adfs-sp-remote', true); - } - } catch (Exception $e) { - \SimpleSAML\Logger::error('Federation: Error loading adfs-idp: ' . $e->getMessage()); - } -} - -foreach ($metaentries['remote'] as $key => $value) { - if (empty($value)) { - unset($metaentries['remote'][$key]); - } -} - -$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_federation.twig'); -$translator = $t->getTranslator(); - -$language = $translator->getLanguage()->getLanguage(); -$fallbackLanguage = 'en'; -$defaultLanguage = $config->getString('language.default', $fallbackLanguage); - -$translators = [ - 'name' => 'name_translated', - 'descr' => 'descr_translated', - 'OrganizationDisplayName' => 'organizationdisplayname_translated', -]; - -foreach ($metaentries['hosted'] as $index => $entity) { - foreach ($translators as $old => $new) { - if (isset($entity[$old][$language])) { - $metaentries['hosted'][$index][$new] = $entity[$old][$language]; - } elseif (isset($entity[$old][$defaultLanguage])) { - $metaentries['hosted'][$index][$new] = $entity[$old][$defaultLanguage]; - } elseif (isset($entity[$old][$fallbackLanguage])) { - $metaentries['hosted'][$index][$new] = $entity[$old][$fallbackLanguage]; - } - } -} -foreach ($metaentries['remote'] as $key => $set) { - foreach ($set as $entityid => $entity) { - foreach ($translators as $old => $new) { - if (isset($entity[$old][$language])) { - $metaentries['remote'][$key][$entityid][$new] = $entity[$old][$language]; - } elseif (isset($entity[$old][$defaultLanguage])) { - $metaentries['remote'][$key][$entityid][$new] = $entity[$old][$defaultLanguage]; - } elseif (isset($entity[$old][$fallbackLanguage])) { - $metaentries['remote'][$key][$entityid][$new] = $entity[$old][$fallbackLanguage]; - } elseif (isset($metaentries['remote'][$key][$entityid][$old])) { - $metaentries['remote'][$key][$entityid][$new] = $metaentries['remote'][$key][$entityid][$old]; - } - } - } -} - -# look up translated string -$mtype = [ - 'saml20-sp-remote' => $translator->noop('{admin:metadata_saml20-sp}'), - 'saml20-sp-hosted' => $translator->noop('{admin:metadata_saml20-sp}'), - 'saml20-idp-remote' => $translator->noop('{admin:metadata_saml20-idp}'), - 'saml20-idp-hosted' => $translator->noop('{admin:metadata_saml20-idp}'), - 'adfs-sp-remote' => $translator->noop('{admin:metadata_adfs-sp}'), - 'adfs-sp-hosted' => $translator->noop('{admin:metadata_adfs-sp}'), - 'adfs-idp-remote' => $translator->noop('{admin:metadata_adfs-idp}'), - 'adfs-idp-hosted' => $translator->noop('{admin:metadata_adfs-idp}'), -]; - -$t->data['pageid'] = 'frontpage_federation'; -$t->data['isadmin'] = $isadmin; -$t->data['loginurl'] = $loginurl; -$t->data['logouturl'] = $logouturl; - -$t->data['links'] = $links; -$t->data['links_welcome'] = $links_welcome; -$t->data['links_config'] = $links_config; -$t->data['links_auth'] = $links_auth; -$t->data['links_federation'] = $links_federation; - -$t->data['metadata_url'] = \SimpleSAML\Module::getModuleURL('core/show_metadata.php'); -$t->data['metaentries'] = $metaentries; -$t->data['mtype'] = $mtype; - -$t->send(); diff --git a/modules/core/www/frontpage_welcome.php b/modules/core/www/frontpage_welcome.php deleted file mode 100644 index 4534387c8..000000000 --- a/modules/core/www/frontpage_welcome.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -// Load SimpleSAMLphp configuration -$config = \SimpleSAML\Configuration::getInstance(); -$session = \SimpleSAML\Session::getSessionFromRequest(); - -// Check if valid local session exists. -if ($config->getBoolean('admin.protectindexpage', false)) { - SimpleSAML\Utils\Auth::requireAdmin(); -} -$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL(); -$loginurl = \SimpleSAML\Utils\Auth::getAdminLoginURL(); -$isadmin = \SimpleSAML\Utils\Auth::isAdmin(); - -$links = []; -$links_welcome = []; -$links_config = []; -$links_auth = []; -$links_federation = []; - -$allLinks = [ - 'links' => &$links, - 'welcome' => &$links_welcome, - 'config' => &$links_config, - 'auth' => &$links_auth, - 'federation' => &$links_federation, -]; - -$links_welcome[] = [ - 'href' => 'https://simplesamlphp.org/docs/stable/', - 'text' => '{core:frontpage:doc_header}', -]; - -\SimpleSAML\Module::callHooks('frontpage', $allLinks); - -$t = new \SimpleSAML\XHTML\Template($config, 'core:frontpage_welcome.twig'); -$t->data['pageid'] = 'frontpage_welcome'; -$t->data['isadmin'] = $isadmin; -$t->data['loginurl'] = $loginurl; -$t->data['logouturl'] = $logouturl; - -$t->data['links'] = $links; -$t->data['links_welcome'] = $links_welcome; -$t->data['links_config'] = $links_config; -$t->data['links_auth'] = $links_auth; -$t->data['links_federation'] = $links_federation; - -$t->send(); diff --git a/modules/core/www/show_metadata.php b/modules/core/www/show_metadata.php deleted file mode 100644 index 6c9e444be..000000000 --- a/modules/core/www/show_metadata.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -// load configuration -$config = \SimpleSAML\Configuration::getInstance(); -$session = \SimpleSAML\Session::getSessionFromRequest(); - -\SimpleSAML\Utils\Auth::requireAdmin(); - -if (!array_key_exists('entityid', $_REQUEST)) { - throw new Exception('required parameter [entityid] missing'); -} -if (!array_key_exists('set', $_REQUEST)) { - throw new Exception('required parameter [set] missing'); -} -if ( - !in_array( - $_REQUEST['set'], - ['saml20-idp-remote', 'saml20-sp-remote'], - true - ) -) { - throw new Exception('Invalid set'); -} - -$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); - -$m = $metadata->getMetaData($_REQUEST['entityid'], $_REQUEST['set']); - -$t = new \SimpleSAML\XHTML\Template($config, 'core:show_metadata.twig'); -$t->data['clipboard.js'] = true; -$t->data['pageid'] = 'show_metadata'; -$t->data['header'] = 'SimpleSAMLphp Show Metadata'; -$t->data['backlink'] = \SimpleSAML\Module::getModuleURL('core/frontpage_federation.php'); -$t->data['m'] = $m; -$t->data['entityid'] = $m['metadata-index']; -unset($m['metadata-index']); -$t->data['metadata'] = var_export($m, true); - -$t->send(); diff --git a/templates/hostnames.twig b/templates/hostnames.twig deleted file mode 100644 index 79f6411f0..000000000 --- a/templates/hostnames.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% set pagetitle = 'Diagnostics on hostname, port and protocol'|trans %} -{% extends "base.twig" %} - -{% block content %} - <h2>{{ pagetitle }}</h2> - {% set items = attributes %} - - {% embed '_table.twig' %} - - {% block namecol %} - <td class="attrname"><samp>{{ name }}</samp></td> - {% endblock %} - - {% block value %} - {{ value }} - {% endblock %} - - {% endembed %} - -{% endblock %} diff --git a/templates/index.twig b/templates/index.twig deleted file mode 100644 index e80a9ad70..000000000 --- a/templates/index.twig +++ /dev/null @@ -1,33 +0,0 @@ -{% extends "base.twig" %} -{% block content %} - <div id="portalmenu" class="ui-tabs ui-widget ui-widget-content ui-corner-all"> - <ul class="tabset_tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"> - <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#">Configuration</a></li> - <li class="ui-state-default ui-corner-top"><a href="/{{ baseurlpath }}module.php/core/frontpage_auth.php">Authentication</a></li> - <li class="ui-state-default ui-corner-top"><a href="/{{ baseurlpath }}module.php/core/frontpage_federation.php">Federation</a></li> - </ul> - <a class='float-r' href='{{ logouturl }}'>{{ '{core:frontpage:logout}'|trans }}</a> - <div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom"> - - <div style="clear: both" class="enablebox mini"> - <table> - - <tr class="disabled"><td>SAML 2.0 IdP</td> - <td><i class="fa fa-ban"></i></td></tr> - - <tr class="disabled"><td>Shib 1.3 IdP</td> - <td><i class="fa fa-ban"></i></td></tr> - - </table> - </div> - <h2>Configuration</h2> - <ul> - {% for url, page in adminpages %} - <li> - <a href="{{ url }}">{{ page }}</a> - </li> - {% endfor %} - </ul> - </div> - </div> -{% endblock content %} diff --git a/templates/metadata-converter.twig b/templates/metadata-converter.twig deleted file mode 100644 index 8c7b5291e..000000000 --- a/templates/metadata-converter.twig +++ /dev/null @@ -1,60 +0,0 @@ -{% set pagetitle = 'Metadata parser'|trans %} -{% extends "base.twig" %} - -{% set i=1 %} -{% block content %} - <h1>{{ pagetitle }}</h1> - <form method="post" class="pure-form" enctype="multipart/form-data" action="#converted"> - <h3>{% trans 'XML metadata' %}</h3> - <div class="pure-control-group"> - <textarea name="xmldata" rows="20" class="text-area edge xmldata">{{ xmldata }}</textarea> - </div> - <br> - <div class="center"> - <div class="pure-button-group two-elements" role="group"> - <label class="pure-button"> - <span class="fa fa-folder-open"></span>{{ 'or select a file:'|trans }} - <input type="file" name="xmlfile" class="hidden" id="file-input"> - </label> - <label id="show-file" class="pure-button hollow show-files" disabled>{{ 'No file selected.'|trans }}</label> - </div> - <br> - <button class="pure-button pure-button-red pure-input-1-3">{{ 'Parse'|trans }}</button> - </div> - </form> - - {% if output -%} - <br> - <h2 id="converted">{{ 'Converted metadata'|trans }}</h2> - {% for type, text in output if text -%} -{# spaceless is to work around a clipboard.js bug that would add extra whitespace #} -{% spaceless %} - <div class="code-box"> - <div class="code-box-title"> - <h3>{{ type }}</h3> - <button data-clipboard-target="#metadata{{ loop.index }}" id="btn{{ loop.index }}" class="pure-button right clipboard-btn copy"> - <i class="fa fa-copy"></i> - </button> - </div> - <div class="code-box-content"> - <pre id="metadata{{ loop.index }}">{{ text|escape }}</pre> - </div> - </div> -{% endspaceless %} - <br><br> - {%- set i=i+1 %} - {%- endfor -%} - {% endif -%} -{% endblock content -%} -{% block postload %} -<script> - $('body').on('change', '#file-input', function () { - var files = this.files; - var fileNames = []; - for (var i = 0; i < files.length; i++) { - fileNames.push(files.item(i).name); - } - $('#show-file').html(fileNames.join(", ")); - }); -</script> -{% endblock postload %} diff --git a/templates/metadata.twig b/templates/metadata.twig deleted file mode 100644 index 1857b4cbb..000000000 --- a/templates/metadata.twig +++ /dev/null @@ -1,62 +0,0 @@ -{% set pagetile = 'SimpleSAMLphp Show Metadata'|trans %} -{% extends 'base.twig' %} -{% block content %} - <h2>{% trans %}Metadata{% endtrans %}</h2> - <dl> - <dd>{{ '{admin:metadata_intro}'|trans }}</dd> - - {% if metaurl is defined %} - <dd>{% trans %}You can get the metadata xml on a dedicated URL:{% endtrans %}</dd> - <dd class="code-box hljs"> - <div class="pure-button-group top-right-corner"> - <a class="pure-button copy hljs" data-clipboard-target="#url" - title="{% trans %}Copy to clipboard{% endtrans %}"><span class="fa fa-copy"></span></a> - <a class="pure-button hljs" href="{{ metaurl }}"> - <span class="fa fa-external-link-square"></span> - </a> - </div> - <code id="url" class="code-box-content">{{ metaurl }}</code> - </dd> - {% endif %} - - <dt>{% trans %}SAML Metadata{% endtrans %}</dt> - <dd>{% trans %}In SAML 2.0 Metadata XML format:{% endtrans %}</dd> - <dd class="code-box hljs"> - <div class="pure-button-group top-right-corner"> - <a class="pure-button copy hljs" data-clipboard-target="#xml-metadata" - title="{% trans %}Copy to clipboard{% endtrans %}"><span class="fa fa-copy"></span></a> - </div> - <div id="xml-metadata" class="code-box-content xml">{{ metadata|raw }}</div> - </dd> - <dt>{% trans %}SimpleSAMLphp Metadata{% endtrans %}</dt> - <dd>{% trans %}Use this if you are using a SimpleSAMLphp entity on - {#- #} the other side:{% endtrans %}</dd> - <dd class="code-box hljs"> - <div class="pure-button-group top-right-corner"> - <a class="pure-button copy hljs" data-clipboard-target="#php-metadata" - title="{% trans %}Copy to clipboard{% endtrans %}"><span class="fa fa-copy"></span></a> - </div> - <div id="php-metadata" class="code-box-content php"> - {#- #}{{ metadataflat|raw }}{# -#} - </div> - </dd> - {% if certdata is defined %} - <dt>{% trans %}Certificates{% endtrans %}</dt> - <p>{% trans %}Download the X509 certificates as PEM-encoded files.{% endtrans %}</p> - - <ul> - {% for cert in certdata %} - - <li> - <a href="{{ cert.url }}"><i class="fa fa-download"></i>{{ cert.name }} - {#- #}{% if cert.signing is defined %}-signing{% endif %} - {#- #}{% if cert.encryption is defined %}-encryption{% endif %}.pem - {#- #}{% if cert.prefix is defined %} ({% trans %}new{% endtrans %}){% endif %}</a> {{ cert.comment }} - </li> - {% endfor %} - - </ul> - {% endif %} - - </dl> -{% endblock content %} diff --git a/tests/www/IndexTest.php b/tests/www/IndexTest.php index 09b92554c..860324a70 100644 --- a/tests/www/IndexTest.php +++ b/tests/www/IndexTest.php @@ -80,7 +80,7 @@ class IndexTest extends TestCase ]); $this->assertEquals('302', $resp['code']); $this->assertEquals( - 'http://example.org/simplesaml/module.php/core/frontpage_welcome.php', + 'http://example.org/simplesaml/module.php/core/login', $resp['headers']['Location'] ); @@ -93,7 +93,7 @@ class IndexTest extends TestCase ]); $this->assertEquals('302', $resp['code']); $this->assertEquals( - 'https://example.org/module.php/core/frontpage_welcome.php', + 'https://example.org/module.php/core/login', $resp['headers']['Location'] ); @@ -106,7 +106,7 @@ class IndexTest extends TestCase ]); $this->assertEquals('302', $resp['code']); $this->assertEquals( - 'http://' . $this->server_addr . '/simplesaml/module.php/core/frontpage_welcome.php', + 'http://' . $this->server_addr . '/simplesaml/module.php/core/login', $resp['headers']['Location'] ); } -- GitLab