From e7818c18f72a4edfea6d4ed1cbf824f293b254d4 Mon Sep 17 00:00:00 2001
From: Jaime Perez <jaime.perez@uninett.no>
Date: Mon, 6 Apr 2020 11:40:32 +0200
Subject: [PATCH] Remove old admin endpoints

---
 www/admin/hostnames.php          | 35 -------------------
 www/admin/index.php              | 31 -----------------
 www/admin/metadata-converter.php | 58 --------------------------------
 www/admin/phpinfo.php            |  8 -----
 4 files changed, 132 deletions(-)
 delete mode 100644 www/admin/hostnames.php
 delete mode 100644 www/admin/index.php
 delete mode 100644 www/admin/metadata-converter.php
 delete mode 100644 www/admin/phpinfo.php

diff --git a/www/admin/hostnames.php b/www/admin/hostnames.php
deleted file mode 100644
index 2948ef12d..000000000
--- a/www/admin/hostnames.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-require_once('../_include.php');
-
-// Load SimpleSAMLphp configuration
-$config = \SimpleSAML\Configuration::getInstance();
-$session = \SimpleSAML\Session::getSessionFromRequest();
-
-// Check if valid local session exists..
-\SimpleSAML\Utils\Auth::requireAdmin();
-
-$attributes = [];
-
-$attributes['HTTP_HOST'] = [$_SERVER['HTTP_HOST']];
-$attributes['HTTPS'] = isset($_SERVER['HTTPS']) ? [$_SERVER['HTTPS']] : [];
-$attributes['SERVER_PROTOCOL'] = [$_SERVER['SERVER_PROTOCOL']];
-$attributes['SERVER_PORT'] = [$_SERVER['SERVER_PORT']];
-
-$attributes['getBaseURL()'] = [\SimpleSAML\Utils\HTTP::getBaseURL()];
-$attributes['getSelfHost()'] = [\SimpleSAML\Utils\HTTP::getSelfHost()];
-$attributes['getSelfHostWithNonStandardPort()'] = [\SimpleSAML\Utils\HTTP::getSelfHostWithNonStandardPort()];
-$attributes['selfURLhost()'] = [\SimpleSAML\Utils\HTTP::getSelfURLHost()];
-$attributes['selfURLNoQuery()'] = [\SimpleSAML\Utils\HTTP::getSelfURLNoQuery()];
-$attributes['getSelfHostWithPath()'] = [\SimpleSAML\Utils\HTTP::getSelfHostWithPath()];
-$attributes['getFirstPathElement()'] = [\SimpleSAML\Utils\HTTP::getFirstPathElement()];
-$attributes['selfURL()'] = [\SimpleSAML\Utils\HTTP::getSelfURL()];
-
-$template = new \SimpleSAML\XHTML\Template($config, 'hostnames.php');
-
-$template->data['remaining']  = $session->getAuthData('admin', 'Expire') - time();
-$template->data['attributes'] = $attributes;
-$template->data['valid'] = 'na';
-$template->data['logout'] = null;
-
-$template->show();
diff --git a/www/admin/index.php b/www/admin/index.php
deleted file mode 100644
index 2541aa1d0..000000000
--- a/www/admin/index.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-require_once('../_include.php');
-
-\SimpleSAML\Utils\HTTP::redirectTrustedURL(\SimpleSAML\Module::getModuleURL('admin/'));
-
-// Load SimpleSAMLphp configuration
-$config = \SimpleSAML\Configuration::getInstance();
-$session = \SimpleSAML\Session::getSessionFromRequest();
-
-// Check if valid local session exists..
-\SimpleSAML\Utils\Auth::requireAdmin();
-
-$adminpages = [
-    'hostnames.php' => 'Diagnostics on hostname, port and protocol',
-    'phpinfo.php' => 'PHP info',
-    '../module.php/sanitycheck/index.php' => 'Sanity check of your SimpleSAMLphp setup',
-    'sandbox.php' => 'Sandbox for testing changes to layout and css',
-];
-
-$logouturl = \SimpleSAML\Utils\Auth::getAdminLogoutURL();
-
-$template = new \SimpleSAML\XHTML\Template($config, 'index.php');
-
-$template->data['pagetitle'] = 'Admin';
-$template->data['adminpages'] = $adminpages;
-$template->data['remaining']  = $session->getAuthData('admin', 'Expire') - time();
-$template->data['valid'] = 'na';
-$template->data['logouturl'] = $logouturl;
-
-$template->show();
diff --git a/www/admin/metadata-converter.php b/www/admin/metadata-converter.php
deleted file mode 100644
index e85446026..000000000
--- a/www/admin/metadata-converter.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-require_once('../_include.php');
-
-use Symfony\Component\VarExporter\VarExporter;
-
-// make sure that the user has admin access rights
-\SimpleSAML\Utils\Auth::requireAdmin();
-
-$config = \SimpleSAML\Configuration::getInstance();
-
-if (!empty($_FILES['xmlfile']['tmp_name'])) {
-    $xmldata = trim(file_get_contents($_FILES['xmlfile']['tmp_name']));
-} elseif (array_key_exists('xmldata', $_POST)) {
-    $xmldata = trim($_POST['xmldata']);
-}
-
-if (!empty($xmldata)) {
-    \SimpleSAML\Utils\XML::checkSAMLMessage($xmldata, 'saml-meta');
-    $entities = \SimpleSAML\Metadata\SAMLParser::parseDescriptorsString($xmldata);
-
-    // get all metadata for the entities
-    foreach ($entities as &$entity) {
-        $entity = [
-            'saml20-sp-remote'  => $entity->getMetadata20SP(),
-            'saml20-idp-remote' => $entity->getMetadata20IdP(),
-        ];
-    }
-
-    // transpose from $entities[entityid][type] to $output[type][entityid]
-    $output = \SimpleSAML\Utils\Arrays::transpose($entities);
-
-    // merge all metadata of each type to a single string which should be added to the corresponding file
-    foreach ($output as $type => &$entities) {
-        $text = '';
-        foreach ($entities as $entityId => $entityMetadata) {
-            if ($entityMetadata === null) {
-                continue;
-            }
-
-            // remove the entityDescriptor element because it is unused, and only makes the output harder to read
-            unset($entityMetadata['entityDescriptor']);
-
-            $text .= '$metadata[' . var_export($entityId, true) . '] = ' .
-                VarExporter::export($entityMetadata) . ";\n";
-        }
-        $entities = $text;
-    }
-} else {
-    $xmldata = '';
-    $output = [];
-}
-
-$template = new \SimpleSAML\XHTML\Template($config, 'metadata-converter.php', 'admin');
-$template->data['clipboard.js'] = true;
-$template->data['xmldata'] = $xmldata;
-$template->data['output'] = $output;
-$template->show();
diff --git a/www/admin/phpinfo.php b/www/admin/phpinfo.php
deleted file mode 100644
index eb46c9377..000000000
--- a/www/admin/phpinfo.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-
-require_once('../_include.php');
-
-// Make sure that the user has admin access rights
-\SimpleSAML\Utils\Auth::requireAdmin();
-
-phpinfo();
-- 
GitLab