proxy-auth: fix check_proxy enforcement and persistence

The proxy IP check was never enforced: ServiceProxyAuth read config
key 'proxy_check' but the property is registered as 'check_proxy',
so the lookup always returned the default empty string and the
else-branch set $sProxyRequest = true unconditionally.

The BOOL property also had SetEncrypted(), which caused getDecrypted()
to call DecryptFromJSON() on a literal bool and fail with
"DecryptFromJSON() invalid $data", so the admin UI never reflected
the saved value. BOOLs are stored as plain bools in JSON; switch to
Get() and drop SetEncrypted() on the property.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Philipp Mundhenk 2026-05-17 09:53:56 +02:00
parent ed35c8e91e
commit 60ee74c68a

View file

@ -6,8 +6,8 @@ class ProxyAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Proxy Auth', NAME = 'Proxy Auth',
AUTHOR = 'Philipp', AUTHOR = 'Philipp',
URL = 'https://www.mundhenk.org/', URL = 'https://www.mundhenk.org/',
VERSION = '0.5', VERSION = '0.6',
RELEASE = '2024-09-20', RELEASE = '2026-05-17',
REQUIRED = '2.36.1', REQUIRED = '2.36.1',
CATEGORY = 'Login', CATEGORY = 'Login',
LICENSE = 'MIT', LICENSE = 'MIT',
@ -84,7 +84,7 @@ class ProxyAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
$sMsg = "ProxyIP: " . $sProxyIP; $sMsg = "ProxyIP: " . $sProxyIP;
$oLogger->Write($sMsg, $sLevel, $sPrefix); $oLogger->Write($sMsg, $sLevel, $sPrefix);
$sProxyCheck = $this->Config()->getDecrypted('plugin', 'proxy_check', ''); $sProxyCheck = (bool) $this->Config()->Get('plugin', 'check_proxy', false);
$sClientIPs = $this->Manager()->Actions()->Http()->GetClientIP(true); $sClientIPs = $this->Manager()->Actions()->Http()->GetClientIP(true);
/* make sure that remote user is only set by authorized proxy to avoid security risks */ /* make sure that remote user is only set by authorized proxy to avoid security risks */
@ -192,8 +192,7 @@ class ProxyAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
->SetLabel('Check Proxy') ->SetLabel('Check Proxy')
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL) ->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
->SetDescription('Activates check if proxy is connecting') ->SetDescription('Activates check if proxy is connecting')
->SetDefaultValue(true) ->SetDefaultValue(true),
->SetEncrypted(),
\RainLoop\Plugins\Property::NewInstance('proxy_ip') \RainLoop\Plugins\Property::NewInstance('proxy_ip')
->SetLabel('Proxy IPNet') ->SetLabel('Proxy IPNet')
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT) ->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)