fix(config): Decrypt sensitive appconfigs when requested

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2026-06-26 12:36:50 +02:00 committed by backportbot[bot]
parent 2d960116bf
commit 0bb230247e
4 changed files with 14 additions and 11 deletions

View file

@ -2955,11 +2955,7 @@
<file src="core/Command/Config/ListConfigs.php">
<DeprecatedMethod>
<code><![CDATA[getFilteredValues]]></code>
<code><![CDATA[getValues]]></code>
</DeprecatedMethod>
<FalsableReturnStatement>
<code><![CDATA[$this->appConfig->getValues($app, false)]]></code>
</FalsableReturnStatement>
</file>
<file src="core/Command/Db/ConvertType.php">
<DeprecatedMethod>

View file

@ -131,7 +131,7 @@ class ListConfigs extends Base {
if ($noSensitiveValues) {
return $this->appConfig->getFilteredValues($app);
} else {
return $this->appConfig->getValues($app, false);
return $this->appConfig->getAllValues($app);
}
}

View file

@ -266,6 +266,13 @@ class AppConfig implements IAppConfig {
);
if (!$filtered) {
foreach ($values as $key => $value) {
$sensitive = $this->isSensitive($app, $key, null);
if ($sensitive && is_string($value) && str_starts_with($value, self::ENCRYPTION_PREFIX)) {
$values[$key] = $this->crypto->decrypt(substr($value, self::ENCRYPTION_PREFIX_LENGTH));
}
}
return $values;
}

View file

@ -107,10 +107,10 @@ class ListConfigsTest extends TestCase {
],
// app config
[
['files', false, [
['files', [
'enabled' => 'yes',
]],
['core', false, [
['core', [
'global_cache_gc_lastrun' => '1430388388',
]],
],
@ -243,10 +243,10 @@ class ListConfigsTest extends TestCase {
],
// app config
[
['files', false, [
['files', [
'enabled' => 'yes',
]],
['core', false, [
['core', [
'global_cache_gc_lastrun' => '1430388388',
]],
],
@ -281,7 +281,7 @@ class ListConfigsTest extends TestCase {
->method('getValue')
->willReturnMap($systemConfigMap);
$this->appConfig->expects($this->any())
->method('getValues')
->method('getAllValues')
->willReturnMap($appConfig);
} else {
$this->systemConfig->expects($this->any())
@ -296,7 +296,7 @@ class ListConfigsTest extends TestCase {
->method('getApps')
->willReturn(['core', 'files']);
$this->appConfig->expects($this->any())
->method('getValues')
->method('getAllValues')
->willReturnMap($appConfig);
$this->consoleInput->expects($this->once())