Skip to content

Commit 5c37f1b

Browse files
Merge pull request #63332 from nextcloud/backport/63311/stable34
[stable34] fix(config): mask the Euro-Office jwt_secret as sensitive
2 parents 9f5f37a + 5f9ab96 commit 5c37f1b

4 files changed

Lines changed: 87 additions & 0 deletions

File tree

lib/private/AppConfig.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,9 @@ private function getSensitiveKeys(string $app): array {
16151615
'call_summary_bot' => [
16161616
'/^secret_(.*)$/',
16171617
],
1618+
'eurooffice' => [
1619+
'/^jwt_secret$/',
1620+
],
16181621
'external' => [
16191622
'/^sites$/',
16201623
'/^jwt_token_privkey_(.*)$/',

lib/private/SystemConfig.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class SystemConfig {
107107
],
108108
],
109109
],
110+
'eurooffice' => [
111+
'jwt_secret' => true,
112+
],
110113
'onlyoffice' => [
111114
'jwt_secret' => true,
112115
],

tests/lib/AppConfigTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,35 @@ public function testWritesAreCached(): void {
202202
$config->setValueString('appid', 'first-key', 'new value');
203203
$this->assertSame('new value', $config->getValueString('appid', 'first-key'));
204204
}
205+
206+
public function testFilteredValuesMaskTheEuroOfficeSecret(): void {
207+
$this->localCache->expects(self::atLeastOnce())
208+
->method('get')
209+
->with('OC\\AppConfig')
210+
->willReturn([
211+
'fastCache' => [
212+
'eurooffice' => [
213+
'jwt_secret' => 'a-document-server-signing-key',
214+
'jwt_header' => 'AuthorizationJwt',
215+
],
216+
],
217+
'lazyCache' => [
218+
'eurooffice' => [],
219+
],
220+
'valueTypes' => [
221+
'eurooffice' => [
222+
'jwt_secret' => AppConfig::VALUE_STRING,
223+
'jwt_header' => AppConfig::VALUE_STRING,
224+
],
225+
],
226+
]);
227+
228+
$this->connection->expects(self::never())->method('getQueryBuilder');
229+
$config = $this->getAppConfig(true);
230+
231+
$this->assertSame([
232+
'jwt_secret' => IConfig::SENSITIVE_VALUE,
233+
'jwt_header' => 'AuthorizationJwt',
234+
], $config->getFilteredValues('eurooffice'));
235+
}
205236
}

tests/lib/SystemConfigTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
8+
9+
namespace Test;
10+
11+
use OC\Config;
12+
use OC\SystemConfig;
13+
use OCP\IConfig;
14+
use PHPUnit\Framework\MockObject\MockObject;
15+
16+
/**
17+
* Class SystemConfigTest
18+
*
19+
* @package Test
20+
*/
21+
class SystemConfigTest extends TestCase {
22+
private Config&MockObject $config;
23+
24+
#[\Override]
25+
protected function setUp(): void {
26+
parent::setUp();
27+
28+
$this->config = $this->createMock(Config::class);
29+
}
30+
31+
public function testGetFilteredValueMasksTheEuroOfficeSecret(): void {
32+
$this->config->method('getValue')
33+
->willReturnMap([
34+
['config_extra_sensitive_values', [], []],
35+
['eurooffice', '', [
36+
'editors_check_interval' => 0,
37+
'jwt_secret' => 'a-document-server-signing-key',
38+
'jwt_header' => 'AuthorizationJwt',
39+
]],
40+
]);
41+
42+
$systemConfig = new SystemConfig($this->config);
43+
44+
$this->assertSame([
45+
'editors_check_interval' => 0,
46+
'jwt_secret' => IConfig::SENSITIVE_VALUE,
47+
'jwt_header' => 'AuthorizationJwt',
48+
], $systemConfig->getFilteredValue('eurooffice'));
49+
}
50+
}

0 commit comments

Comments
 (0)