mirror of
https://github.com/typemill/typemill.git
synced 2025-07-31 19:30:40 +02:00
added proxy support
This commit is contained in:
@@ -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": {
|
||||
|
54
composer.lock
generated
54
composer.lock
generated
@@ -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"
|
||||
}
|
||||
|
@@ -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).
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class SettingsController extends Controller
|
||||
$route = $request->getAttribute('route');
|
||||
$navigation = $this->getNavigation();
|
||||
|
||||
$content = '<h1>Hello</h1>';
|
||||
$content = '<h1>Hello</h1><p>I am the showBlank method from the settings controller</p><p>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.</p>';
|
||||
|
||||
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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -174,7 +174,9 @@ class Settings
|
||||
'latestVersion' => true,
|
||||
'logo' => true,
|
||||
'favicon' => true,
|
||||
'twigcache' => true
|
||||
'twigcache' => true,
|
||||
'proxy' => true,
|
||||
'trustedproxies' => true,
|
||||
];
|
||||
|
||||
# cleanup the existing usersettings
|
||||
|
@@ -187,6 +187,20 @@
|
||||
<span class="error">{{ errors.settings.images.live.height | first }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="medium{{ errors.settings.proxy ? ' error' : '' }}">
|
||||
<label for="settings[proxy]">{{ __('Proxy') }}</label>
|
||||
<label class="control-group">{{ __('Use X-Forwarded Headers') }}
|
||||
<input name="settings[proxy]" type="checkbox" {% if (settings.proxy or old.settings.proxy) %} checked {% endif %}>
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="medium{{ errors.settings.trustedproxies ? ' error' : '' }}">
|
||||
<label for="trustedproxies">{{ __('Trusted IPs for proxy (comma separated)') }}</label>
|
||||
<input type="text" name="settings[trustedproxies]" id="trustedproxies" value="{{ old.settings.trustedproxies ? old.settings.trustedproxies : settings.trustedproxies }}" title="{{ __('Comma separated list of IPs') }}" />
|
||||
{% if errors.settings.trustedproxies %}
|
||||
<span class="error">{{ errors.settings.trustedproxies | first }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</fieldset>
|
||||
</section>
|
||||
<input type="submit" value="{{ __('Save All Settings') }}" />
|
||||
|
@@ -48,6 +48,12 @@ $app = new \Slim\App($settings);
|
||||
|
||||
$container = $app->getContainer();
|
||||
|
||||
if($settings['settings']['proxy'])
|
||||
{
|
||||
$trustedProxies = isset($settings['settings']['trustedproxies']) ? explode(",", $settings['settings']['trustedproxies']) : [];
|
||||
$app->add(new RKA\Middleware\ProxyDetection($trustedProxies));
|
||||
}
|
||||
|
||||
/************************
|
||||
* LOAD & UPDATE PLUGINS *
|
||||
************************/
|
||||
@@ -242,9 +248,10 @@ $container['view'] = function ($container) use ($uri)
|
||||
$view->addExtension(new Typemill\Extensions\TwigMarkdownExtension());
|
||||
$view->addExtension(new Typemill\Extensions\TwigMetaExtension());
|
||||
$view->addExtension(new Typemill\Extensions\TwigPagelistExtension());
|
||||
|
||||
|
||||
# use {{ base_url() }} in twig templates
|
||||
$view['base_url'] = $uri->getBaseUrl();
|
||||
$view['base_url'] = $basePath;
|
||||
$view['current_url'] = $uri->getPath();
|
||||
|
||||
/* if session route, add flash messages and csrf-protection */
|
||||
|
Reference in New Issue
Block a user