diff --git a/composer.json b/composer.json index f180aa1..bdc3889 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "erusev/parsedown-extra": "dev-master", "jbroadway/urlify": "1.1.3", "vlucas/valitron": "dev-master", - "laminas/laminas-permissions-acl": "^2.7" + "laminas/laminas-permissions-acl": "^2.7", + "akrabat/proxy-detection-middleware": "^0.4.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 1eddddc..e661174 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,57 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "87094a87b3a795ce73c299e4535358fb", + "content-hash": "7539fdddfa1c0b8d030fa5955b45a928", "packages": [ + { + "name": "akrabat/proxy-detection-middleware", + "version": "0.4", + "source": { + "type": "git", + "url": "https://github.com/akrabat/proxy-detection-middleware.git", + "reference": "226be882e2cce69b7f4140d8fb2e73147317a8a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/akrabat/proxy-detection-middleware/zipball/226be882e2cce69b7f4140d8fb2e73147317a8a2", + "reference": "226be882e2cce69b7f4140d8fb2e73147317a8a2", + "shasum": "" + }, + "require": { + "psr/http-message": "^1.0" + }, + "require-dev": { + "php": ">=7.0", + "phpunit/phpunit": "^6", + "squizlabs/php_codesniffer": "^2.3", + "zendframework/zend-diactoros": "^1.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "RKA\\Middleware\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Rob Allen", + "email": "rob@akrabat.com", + "homepage": "http://akrabat.com" + } + ], + "description": "PSR-7 Middleware that determines the scheme, host and port from the 'X-Forwarded-Proto', 'X-Forwarded-Host' and 'X-Forwarded-Port' headers and updates the Request's Uri object.", + "homepage": "http://github.com/akrabat/proxy-detection-middleware", + "keywords": [ + "IP", + "middleware", + "psr7" + ], + "time": "2018-09-11T10:28:26+00:00" + }, { "name": "erusev/parsedown", "version": "1.8.0-beta-7", @@ -1025,5 +1074,6 @@ "prefer-stable": true, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/content/00-welcome/02-get-help.md b/content/00-welcome/02-get-help.md index 148b2c6..b121e36 100644 --- a/content/00-welcome/02-get-help.md +++ b/content/00-welcome/02-get-help.md @@ -1,6 +1,6 @@ # Get Help -If you need any help, then please read the [documentation on typemill.net](https://typemill.net/typemill) first. Some short video-tutorials are in work right now. +If you need any help, then please read the [documentation on typemill.net](https://typemill.net/typemill) first. Some short video-tutorials are in work right now. [linktest](/welcome) If you found a bug or if you have a question, then please open a new issue on [GitHub](https://github.com/typemill/typemill/issues). diff --git a/system/Controllers/SettingsController.php b/system/Controllers/SettingsController.php index 0762b6f..9ac4dd8 100644 --- a/system/Controllers/SettingsController.php +++ b/system/Controllers/SettingsController.php @@ -23,7 +23,7 @@ class SettingsController extends Controller $route = $request->getAttribute('route'); $navigation = $this->getNavigation(); - $content = '
I am the showBlank method from the settings controller
In most cases I have been called from a plugin. But if you see this content, then the plugin does not work or has forgotten to inject its own content.
'; return $this->render($response, 'settings/blank.twig', array( 'settings' => $settings, @@ -40,7 +40,7 @@ class SettingsController extends Controller *********************/ public function showSettings($request, $response, $args) - { + { $user = new User(); $settings = $this->c->get('settings'); $defaultSettings = \Typemill\Settings::getDefaultSettings(); @@ -96,11 +96,13 @@ class SettingsController extends Controller 'language' => $newSettings['language'], 'langattr' => $newSettings['langattr'], 'editor' => $newSettings['editor'], - 'access' => $newSettings['access'], + 'access' => $newSettings['access'], 'formats' => $newSettings['formats'], 'headlineanchors' => isset($newSettings['headlineanchors']) ? $newSettings['headlineanchors'] : null, 'displayErrorDetails' => isset($newSettings['displayErrorDetails']) ? true : null, - 'twigcache' => isset($newSettings['twigcache']) ? true : null + 'twigcache' => isset($newSettings['twigcache']) ? true : null, + 'proxy' => isset($newSettings['proxy']) ? true : null, + 'trustedproxies' => $newSettings['trustedproxies'] ); # https://www.slimframework.com/docs/v3/cookbook/uploading-files.html; diff --git a/system/Models/Validation.php b/system/Models/Validation.php index fedb492..0391abe 100644 --- a/system/Models/Validation.php +++ b/system/Models/Validation.php @@ -50,6 +50,19 @@ class Validation return false; }, 'does not exist'); + Validator::addRule('iplist', function($field, $value, array $params, array $fields) use ($user) + { + $iplist = explode(",", $value); + foreach($iplist as $ip) + { + if( filter_var( trim($ip), \FILTER_VALIDATE_IP) === false) + { + return false; + } + } + return true; + }, 'contains one or more invalid ip-adress'); + Validator::addRule('checkPassword', function($field, $value, array $params, array $fields) use ($user) { $userdata = $user->getUser($fields['username']); @@ -218,6 +231,7 @@ class Validation $v->rule('in', 'editor', ['raw', 'visual']); $v->rule('values_allowed', 'formats', $formats); $v->rule('in', 'copyright', $copyright); + $v->rule('iplist', 'trustedproxies'); return $this->validationResult($v, $name); } diff --git a/system/Settings.php b/system/Settings.php index 27c9fc9..6119810 100644 --- a/system/Settings.php +++ b/system/Settings.php @@ -174,7 +174,9 @@ class Settings 'latestVersion' => true, 'logo' => true, 'favicon' => true, - 'twigcache' => true + 'twigcache' => true, + 'proxy' => true, + 'trustedproxies' => true, ]; # cleanup the existing usersettings diff --git a/system/author/settings/system.twig b/system/author/settings/system.twig index 9eb29a3..3779cb5 100644 --- a/system/author/settings/system.twig +++ b/system/author/settings/system.twig @@ -187,6 +187,20 @@ {{ errors.settings.images.live.height | first }} {% endif %} +