예제 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $key = new PrivateKey($this->fs->get($this->argument('keyPath')));
     $key->unlock(md5($this->ask('What is the master key secret?')));
     $entry = Entry::where('id', $this->argument('id'))->first();
     $masterShare = $entry->keyShares()->whereNull('user_id')->firstOrFail();
     $this->output->writeln("Password:");
     $this->output->writeln($this->sealer->unseal($entry->data, $masterShare->public, $key));
 }
예제 #2
0
 private function getKey(Request $request, Entry $entry)
 {
     $userAndKey = $this->apiKey->extractKeyAndUser($request);
     $share = $entry->keyShares()->where('user_id', $userAndKey['user']->id)->firstOrFail();
     if ($share) {
         $this->logger->log('entry', 'Accessed entry via API', $entry->id);
         return $entry->toArray() + ['password' => $this->sealer->unseal($entry->data, $share->public, $userAndKey['key'])];
     }
     return null;
 }
예제 #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $user = User::where('email', $this->argument('email'))->first();
     $key = new PrivateKey($this->fs->get($this->argument('keyPath')));
     $key->unlock(md5($this->ask('What is the master key secret?')));
     $entries = KeyShare::where('user_id', $user->id)->with('entry')->get();
     foreach ($entries as $share) {
         $masterShare = $share->entry->keyShares()->whereNull('user_id')->firstOrFail();
         $data = $this->sealer->unseal($share->entry->data, $masterShare->public, $key);
         $this->crypt->encrypt($data, $share->entry);
     }
 }