aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2017-05-30 12:54:58 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2017-07-06 11:47:10 +0200
commit28a7e72868017fb545e8303f32c1204ffc4cc8c1 (patch)
treefe2e01f2ac3a6b4e881fdcb730c2f7a0b763fc02
parentda51ec38f4174532e83a4fde21f4c523e4f0bc7c (diff)
downloadnextcloud-server-28a7e72868017fb545e8303f32c1204ffc4cc8c1.tar.gz
nextcloud-server-28a7e72868017fb545e8303f32c1204ffc4cc8c1.zip
after the master key was loaded we are ready to go, no re-login needed
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
-rw-r--r--apps/encryption/appinfo/app.php1
-rw-r--r--apps/encryption/lib/AppInfo/Application.php7
-rw-r--r--apps/encryption/lib/KeyManager.php13
3 files changed, 17 insertions, 4 deletions
diff --git a/apps/encryption/appinfo/app.php b/apps/encryption/appinfo/app.php
index 950166dca2b..4f54f0e7251 100644
--- a/apps/encryption/appinfo/app.php
+++ b/apps/encryption/appinfo/app.php
@@ -31,4 +31,5 @@ $app = new Application([], $encryptionSystemReady);
if ($encryptionSystemReady) {
$app->registerEncryptionModule();
$app->registerHooks();
+ $app->setUp();
}
diff --git a/apps/encryption/lib/AppInfo/Application.php b/apps/encryption/lib/AppInfo/Application.php
index 56c2dafdabd..c047489cec3 100644
--- a/apps/encryption/lib/AppInfo/Application.php
+++ b/apps/encryption/lib/AppInfo/Application.php
@@ -67,7 +67,11 @@ class Application extends \OCP\AppFramework\App {
$session = $this->getContainer()->query('Session');
$session->setStatus(Session::RUN_MIGRATION);
}
- if ($this->encryptionManager->isEnabled() && $encryptionSystemReady) {
+
+ }
+
+ public function setUp() {
+ if ($this->encryptionManager->isEnabled()) {
/** @var Setup $setup */
$setup = $this->getContainer()->query('UserSetup');
$setup->setupSystem();
@@ -77,7 +81,6 @@ class Application extends \OCP\AppFramework\App {
/**
* register hooks
*/
-
public function registerHooks() {
if (!$this->config->getSystemValue('maintenance', false)) {
diff --git a/apps/encryption/lib/KeyManager.php b/apps/encryption/lib/KeyManager.php
index 6b260c39bfb..6039aaaaa0e 100644
--- a/apps/encryption/lib/KeyManager.php
+++ b/apps/encryption/lib/KeyManager.php
@@ -179,8 +179,8 @@ class KeyManager {
return;
}
- $masterKey = $this->getPublicMasterKey();
- if (empty($masterKey)) {
+ $publicMasterKey = $this->getPublicMasterKey();
+ if (empty($publicMasterKey)) {
$keyPair = $this->crypt->createKeyPair();
// Save public key
@@ -193,6 +193,15 @@ class KeyManager {
$header = $this->crypt->generateHeader();
$this->setSystemPrivateKey($this->masterKeyId, $header . $encryptedKey);
}
+
+ if (!$this->session->isPrivateKeySet()) {
+ $masterKey = $this->getSystemPrivateKey($this->masterKeyId);
+ $decryptedMasterKey = $this->crypt->decryptPrivateKey($masterKey, $this->getMasterKeyPassword(), $this->masterKeyId);
+ $this->session->setPrivateKey($decryptedMasterKey);
+ }
+
+ // after the encryption key is available we are ready to go
+ $this->session->setStatus(Session::INIT_SUCCESSFUL);
}
/**