Skip to content

Commit

Permalink
Merge pull request #35600 from nextcloud/fix/empty-secret-migration-f…
Browse files Browse the repository at this point in the history
…iles-external

Fix migration to non-empty secret
  • Loading branch information
szaimen authored Dec 6, 2022
2 parents decf2b4 + 5e31ed4 commit 28358ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion apps/files_external/lib/Lib/Auth/PublicKey/RSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = n
$auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
// Add fallback routine for a time where secret was not enforced to be exists
$auth->setPassword('');
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
}
}
$storage->setBackendOption('public_key_auth', $auth);
}
Expand Down
6 changes: 5 additions & 1 deletion apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = n
$auth = new RSACrypt();
$auth->setPassword($this->config->getSystemValue('secret', ''));
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
// Add fallback routine for a time where secret was not enforced to be exists
$auth->setPassword('');
if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
throw new \RuntimeException('unable to load private key');
}
}
$storage->setBackendOption('public_key_auth', $auth);
}
Expand Down

0 comments on commit 28358ac

Please sign in to comment.