Skip to content

Change to re-create masterkeys#6

Closed
sharidas wants to merge 1 commit into
masterfrom
recreate-masterkey-task
Closed

Change to re-create masterkeys#6
sharidas wants to merge 1 commit into
masterfrom
recreate-masterkey-task

Conversation

@sharidas

Copy link
Copy Markdown
Contributor

This change brings a new command to re-create
masterkey

Signed-off-by: Sujith H sharidasan@owncloud.com

@PVince81 PVince81 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good progress. There are still a few changes needed.

}

protected function execute(InputInterface $input, OutputInterface $output) {
if ($this->util->isMasterKeyEnabled()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a warning here before starting and asking whether to proceed "Y/N". Please check how warnings are displayed for the other encryption commands. Also add a "-y" option to answer yes automatically.

Considering that this will decrypt a whole instance and might take days, we better inform the admin in advance before starting.

cc @tomneedham

Comment thread lib/Command/RecreateMasterKey.php Outdated
$progress->finish();
$output->writeln("\nEncryption completed successfully\n");
} else {
$output->writeln("Master key is not enabled. Kindly enable it\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the "Kindly" bit. The instance might be in "user key" mode

Comment thread lib/Command/RecreateMasterKey.php Outdated
}

public function encryptAllUsersFiles(ProgressBar $progress) {
$userNo = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start at zero ?

Comment thread lib/Command/RecreateMasterKey.php Outdated
}
}

public function encryptUsersFiles($uid, ProgressBar $progress) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any code from the occ encrypt-all command we could reuse ?

Comment thread lib/Command/RecreateMasterKey.php Outdated
protected $appConfig;

/** @var IConfig */
protected $IConfig;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local attributes must start with a lower case and be camel case.

}
}

if (empty($this->failed)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show error in case of failure ? an admin might want to ctrl+c when seeing this in real-time

Comment thread tests/Command/RecreateMasterKeyTest.php Outdated
protected $appConfig;

/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
protected $IConfig;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on attribute casing above

@PVince81 PVince81 added this to the development milestone Jul 24, 2017
@sharidas sharidas force-pushed the recreate-masterkey-task branch 2 times, most recently from a69526c to cc7bbcb Compare July 28, 2017 14:29
$this->keyManager, $this->util, $this->config,
$this->mailer, $this->l, $this->questionHelper,
$this->secureRandom);
$this->encryptAll->encryptAll($input, $output);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We call encryptAll here. Reusing old code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we use encrypt all. Let me also see if we can reuse decrypt all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mistake, its better to stick on with the decrypt implemented here. The final output of a decryptall is again encrypted. Which is not the result we want.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment to clarify this, in case future developers wonder about the same question ?

@sharidas sharidas force-pushed the recreate-masterkey-task branch 2 times, most recently from a19ae76 to 5ebdd9e Compare July 31, 2017 12:30

protected function encryptAllUsers(InputInterface $input, OutputInterface $output) {
/*
* We are reusing the encryptAll code but not the decryptAll. The reason being

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added doc which says why we are not using decryptAll and re-using encryptAll. This should help future devs understand why we used this approach.

@PVince81 PVince81 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍, assuming you tested it and it still works

@sharidas

sharidas commented Jul 31, 2017

Copy link
Copy Markdown
Contributor Author

Testing done as follows:

  • Created user admin and created files.
  • Tried to modify the files.
  • Ran the command. Relogin as admin user and verified the files were readable.
  • Created another user user1 and did the same procedure on both admin and user1

Testing done with external storage:

  • Create a file and move to the external storage.
  • Now try to update the file
  • Run the command from the location where the file was initially created.
  • After relogin, the file was readable. Done this exercise multiple times.

@sharidas sharidas force-pushed the recreate-masterkey-task branch 2 times, most recently from afe97a5 to 71f182d Compare July 31, 2017 17:08
@CLAassistant

CLAassistant commented Jul 31, 2017

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sharidas sharidas force-pushed the recreate-masterkey-task branch from 71f182d to 775a4d0 Compare July 31, 2017 17:11
@sharidas sharidas force-pushed the recreate-masterkey-task branch 13 times, most recently from 3749e30 to fd11f85 Compare August 21, 2017 10:07
This change brings a new command to re-create
masterkey

Signed-off-by: Sujith H <sharidasan@owncloud.com>
@sharidas sharidas force-pushed the recreate-masterkey-task branch from fd11f85 to 2b1eb3e Compare August 21, 2017 12:14
@sharidas

Copy link
Copy Markdown
Contributor Author

Closing this PR. We have #12 to track.

@sharidas sharidas closed this Aug 31, 2017
@patrickjahns patrickjahns removed this from the QA milestone Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants