Merge pull request #59314 from nextcloud/backport/59202/stable33
Some checks failed
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Integration sqlite / changes (push) Waiting to run
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, --tags ~@large files_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, capabilities_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, collaboration_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, comments_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, dav_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, federation_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, file_conversions) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, files_reminders) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, filesdrop_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, ldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, openldap_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, openldap_numerical_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, remoteapi_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, routing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, setup_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, sharees_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, sharing_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, theming_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite (stable33, 8.4, stable33, videoverification_features) (push) Blocked by required conditions
Integration sqlite / integration-sqlite-summary (push) Blocked by required conditions
Psalm static code analysis / static-code-analysis (push) Has been cancelled
Psalm static code analysis / static-code-analysis-security (push) Has been cancelled
Psalm static code analysis / static-code-analysis-ocp (push) Has been cancelled
Psalm static code analysis / static-code-analysis-ncu (push) Has been cancelled

[stable33] fix: cache validation of system keys
This commit is contained in:
Robin Appelman 2026-04-07 23:38:47 +02:00 committed by GitHub
commit 13d5fcaaf4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 3 deletions

View file

@ -9,13 +9,18 @@ namespace OCA\Encryption\Users;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCP\ICache;
use OCP\ICacheFactory;
class Setup {
private readonly ICache $cache;
public function __construct(
private Crypt $crypt,
private KeyManager $keyManager,
ICacheFactory $cacheFactory,
) {
$this->cache = $cacheFactory->createLocal('encryption-setup');
}
/**
@ -35,7 +40,10 @@ class Setup {
* make sure that all system keys exists
*/
public function setupSystem() {
$this->keyManager->validateShareKey();
$this->keyManager->validateMasterKey();
if (!$this->cache->get('keys-validated')) {
$this->keyManager->validateShareKey();
$this->keyManager->validateMasterKey();
$this->cache->set('keys-validated', true);
}
}
}

View file

@ -13,6 +13,7 @@ namespace OCA\Encryption\Tests\Command;
use OC\Files\SetupManager;
use OC\Files\View;
use OCA\Encryption\Command\FixEncryptedVersion;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Util;
use OCP\Encryption\IManager;
use OCP\IAppConfig;
@ -49,6 +50,8 @@ class FixEncryptedVersionTest extends TestCase {
public function setUp(): void {
parent::setUp();
Server::get(KeyManager::class)->validateMasterKey();
Server::get(KeyManager::class)->validateShareKey();
Server::get(IAppConfig::class)->setValueBool('encryption', 'useMasterKey', true);

View file

@ -11,6 +11,7 @@ namespace OCA\encryption\tests;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\View;
use OCA\Encryption\KeyManager;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Server;
@ -30,6 +31,8 @@ class EncryptedStorageTest extends TestCase {
use UserTrait;
public function testMoveFromEncrypted(): void {
Server::get(KeyManager::class)->validateMasterKey();
Server::get(KeyManager::class)->validateShareKey();
$this->createUser('test1', 'test2');
$this->setupForUser('test1', 'test2');

View file

@ -12,6 +12,8 @@ namespace OCA\Encryption\Tests\Users;
use OCA\Encryption\Crypto\Crypt;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCP\ICache;
use OCP\ICacheFactory;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
@ -32,9 +34,16 @@ class SetupTest extends TestCase {
->disableOriginalConstructor()
->getMock();
$cache = $this->createMock(ICache::class);
$cacheFactory = $this->createMock(ICacheFactory::class);
$cacheFactory->method('createLocal')
->willReturn($cache);
$this->instance = new Setup(
$this->cryptMock,
$this->keyManagerMock);
$this->keyManagerMock,
$cacheFactory,
);
}