Merge pull request #44640 from nextcloud/fix/noid/returns-real-value-on-details

fix(appconfig): returns correct value on details
This commit is contained in:
Maxence Lange 2024-04-18 07:05:15 -01:00 committed by GitHub
commit b75bb088d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View File

@ -173,8 +173,8 @@ class SetConfig extends Base {
*/ */
$sensitive = $input->getOption('sensitive'); $sensitive = $input->getOption('sensitive');
try { try {
$currSensitive = $this->appConfig->isLazy($appName, $configName); $currSensitive = $this->appConfig->isSensitive($appName, $configName, null);
if ($sensitive === null || $sensitive === $currSensitive || !$this->ask($input, $output, ($sensitive) ? 'LAZY' : 'NOT LAZY')) { if ($sensitive === null || $sensitive === $currSensitive || !$this->ask($input, $output, ($sensitive) ? 'SENSITIVE' : 'NOT SENSITIVE')) {
$sensitive = $currSensitive; $sensitive = $currSensitive;
} }
} catch (AppConfigUnknownKeyException) { } catch (AppConfigUnknownKeyException) {

View File

@ -1034,14 +1034,20 @@ class AppConfig implements IAppConfig {
throw new AppConfigUnknownKeyException('unknown config key'); throw new AppConfigUnknownKeyException('unknown config key');
} }
$value = $cache[$app][$key];
$sensitive = $this->isSensitive($app, $key, null);
if ($sensitive && str_starts_with($value, self::ENCRYPTION_PREFIX)) {
$value = $this->crypto->decrypt(substr($value, self::ENCRYPTION_PREFIX_LENGTH));
}
return [ return [
'app' => $app, 'app' => $app,
'key' => $key, 'key' => $key,
'value' => $cache[$app][$key], 'value' => $value,
'type' => $type, 'type' => $type,
'lazy' => $lazy, 'lazy' => $lazy,
'typeString' => $typeString, 'typeString' => $typeString,
'sensitive' => $this->isSensitive($app, $key, null) 'sensitive' => $sensitive
]; ];
} }

View File

@ -1253,7 +1253,7 @@ class AppConfigTest extends TestCase {
[ [
'app' => 'sensitive-app', 'app' => 'sensitive-app',
'key' => 'lazy-key', 'key' => 'lazy-key',
'value' => $this->baseStruct['sensitive-app']['lazy-key']['encrypted'], 'value' => 'value',
'type' => 4, 'type' => 4,
'lazy' => true, 'lazy' => true,
'typeString' => 'string', 'typeString' => 'string',