From af93171c52910dcae4165533e01c8461a696b9c1 Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Fri, 24 Nov 2023 14:15:54 -0800 Subject: [PATCH] Updated deps, added in 8.3 to tests, and fixed the biggest bug --- .github/workflows/unittests.yml | 2 +- composer.lock | 79 ++++++++++++++++---------------- src/Plugins/Admin/Admin.php | 4 ++ src/Plugins/Admin/Controller.php | 11 +++++ src/index.php | 8 +--- 5 files changed, 57 insertions(+), 47 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index f504be5..7db5b97 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php_version: [8.0, 8.1, 8.2] + php_version: [8.0, 8.1, 8.2, 8.3] steps: - uses: actions/checkout@v4 diff --git a/composer.lock b/composer.lock index aa46f6d..15e388a 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "antcms/antloader", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/AntCMS-org/AntLoader.git", - "reference": "ce5aeeb28544b85150382989d463b8dc71efec87" + "reference": "fcf0f55980af0090788ee5eb8ff39eb36ddc40d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/AntCMS-org/AntLoader/zipball/ce5aeeb28544b85150382989d463b8dc71efec87", - "reference": "ce5aeeb28544b85150382989d463b8dc71efec87", + "url": "https://api.github.com/repos/AntCMS-org/AntLoader/zipball/fcf0f55980af0090788ee5eb8ff39eb36ddc40d3", + "reference": "fcf0f55980af0090788ee5eb8ff39eb36ddc40d3", "shasum": "" }, "require": { @@ -47,9 +47,9 @@ "description": "A small and simple autoloader for PHP applications", "support": { "issues": "https://github.com/AntCMS-org/AntLoader/issues", - "source": "https://github.com/AntCMS-org/AntLoader/tree/2.0.2" + "source": "https://github.com/AntCMS-org/AntLoader/tree/2.0.3" }, - "time": "2023-10-03T13:13:17+00:00" + "time": "2023-11-20T19:35:21+00:00" }, { "name": "composer/ca-bundle", @@ -1134,16 +1134,16 @@ }, { "name": "nyholm/psr7", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/Nyholm/psr7.git", - "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be" + "reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Nyholm/psr7/zipball/3cb4d163b58589e47b35103e8e5e6a6a475b47be", - "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/aa5fc277a4f5508013d571341ade0c3886d4d00e", + "reference": "aa5fc277a4f5508013d571341ade0c3886d4d00e", "shasum": "" }, "require": { @@ -1196,7 +1196,7 @@ ], "support": { "issues": "https://github.com/Nyholm/psr7/issues", - "source": "https://github.com/Nyholm/psr7/tree/1.8.0" + "source": "https://github.com/Nyholm/psr7/tree/1.8.1" }, "funding": [ { @@ -1208,7 +1208,7 @@ "type": "github" } ], - "time": "2023-05-02T11:26:24+00:00" + "time": "2023-11-13T09:31:12+00:00" }, { "name": "nyholm/psr7-server", @@ -2005,7 +2005,7 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", @@ -2052,7 +2052,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" }, "funding": [ { @@ -2384,16 +2384,16 @@ }, { "name": "symfony/yaml", - "version": "v6.3.7", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "9758b6c69d179936435d0ffb577c3708d57e38a8" + "reference": "3493af8a8dad7fa91c77fa473ba23ecd95334a92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/9758b6c69d179936435d0ffb577c3708d57e38a8", - "reference": "9758b6c69d179936435d0ffb577c3708d57e38a8", + "url": "https://api.github.com/repos/symfony/yaml/zipball/3493af8a8dad7fa91c77fa473ba23ecd95334a92", + "reference": "3493af8a8dad7fa91c77fa473ba23ecd95334a92", "shasum": "" }, "require": { @@ -2436,7 +2436,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v6.3.7" + "source": "https://github.com/symfony/yaml/tree/v6.3.8" }, "funding": [ { @@ -2452,30 +2452,31 @@ "type": "tidelift" } ], - "time": "2023-10-28T23:31:00+00:00" + "time": "2023-11-06T10:58:05+00:00" }, { "name": "twig/twig", - "version": "v3.7.1", + "version": "v3.8.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554" + "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", - "reference": "a0ce373a0ca3bf6c64b9e3e2124aca502ba39554", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", + "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d", "shasum": "" }, "require": { "php": ">=7.2.5", "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3" + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php80": "^1.22" }, "require-dev": { "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.3" + "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0" }, "type": "library", "autoload": { @@ -2511,7 +2512,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.7.1" + "source": "https://github.com/twigphp/Twig/tree/v3.8.0" }, "funding": [ { @@ -2523,7 +2524,7 @@ "type": "tidelift" } ], - "time": "2023-08-28T11:09:02+00:00" + "time": "2023-11-21T18:54:41+00:00" } ], "packages-dev": [ @@ -2825,16 +2826,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.41", + "version": "1.10.44", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c6174523c2a69231df55bdc65b61655e72876d76" + "reference": "bf84367c53a23f759513985c54ffe0d0c249825b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c6174523c2a69231df55bdc65b61655e72876d76", - "reference": "c6174523c2a69231df55bdc65b61655e72876d76", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bf84367c53a23f759513985c54ffe0d0c249825b", + "reference": "bf84367c53a23f759513985c54ffe0d0c249825b", "shasum": "" }, "require": { @@ -2883,7 +2884,7 @@ "type": "tidelift" } ], - "time": "2023-11-05T12:57:57+00:00" + "time": "2023-11-21T16:30:46+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4334,16 +4335,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", "shasum": "" }, "require": { @@ -4372,7 +4373,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" }, "funding": [ { @@ -4380,7 +4381,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2023-11-20T00:12:19+00:00" } ], "aliases": [ diff --git a/src/Plugins/Admin/Admin.php b/src/Plugins/Admin/Admin.php index 7edf0a0..58310ee 100644 --- a/src/Plugins/Admin/Admin.php +++ b/src/Plugins/Admin/Admin.php @@ -28,6 +28,10 @@ class Admin extends AntPlugin { $this->antAuth = new AntAuth; $this->antTwig = new AntTwig; + } + + public function checkAuth() + { $this->antAuth->checkAuth(); } diff --git a/src/Plugins/Admin/Controller.php b/src/Plugins/Admin/Controller.php index 0b0d3e6..c2d3ee9 100644 --- a/src/Plugins/Admin/Controller.php +++ b/src/Plugins/Admin/Controller.php @@ -13,66 +13,77 @@ class Controller $adminPlugin = new Admin; $app->get('/admin', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->renderIndex(); }); $app->get('/admin/config', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->config(); }); $app->get('/admin/config/edit', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->editConfig(); }); $app->post('/admin/config/save', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->saveConfig(); }); $app->get('/admin/users', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->users(); }); $app->get('/admin/users/add', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->addUser(); }); $app->get('/admin/users/edit/{username}', function (Request $request, Response $response, array $args) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->editUser($args); }); $app->get('/admin/users/resetpassword/{username}', function (Request $request, Response $response, array $args) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->resetpassword($args); }); $app->post('/admin/user/save', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->saveUser(); }); $app->post('/admin/user/savenew', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->saveUser(); }); $app->get('/admin/pages/regenerate', function (Request $request, Response $response) use ($adminPlugin) { + $adminPlugin->checkAuth(); $adminPlugin->setRequest($request); $adminPlugin->SetResponse($response); return $adminPlugin->regeneratePages(); diff --git a/src/index.php b/src/index.php index 45acbcb..efc9caa 100644 --- a/src/index.php +++ b/src/index.php @@ -55,7 +55,7 @@ $app->get('/.well-known/acme-challenge/{path:.*}', function (Request $request, R return $antCMS->serveContent(); }); -$app->get('/', function (Request $request, Response $response) use ($antCMS) { +$app->get('/{path:.*}', function (Request $request, Response $response) use ($antCMS) { if (!file_exists(antUsersList)) { AntCMS::redirectWithoutRequest('/profile/firsttime'); } @@ -65,10 +65,4 @@ $app->get('/', function (Request $request, Response $response) use ($antCMS) { return $antCMS->renderPage(); }); -$app->get('/{path:.*}', function (Request $request, Response $response) use ($antCMS) { - $antCMS->setRequest($request); - $antCMS->SetResponse($response); - return $antCMS->renderPage(); -}); - $app->run();