示例#1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach (User::all() as $user) {
         if (!$user->rsaKey) {
             throw new \RuntimeException('user ' . $user->email . ' has no RSA key. Create it using key:generate:users');
         }
     }
     if (!$this->filesystem->exists(config('app.backup_key'))) {
         $this->warn('Backup key does not exist. We recommend that you create one using key:generate:master');
     }
     $entries = Entry::all();
     foreach ($entries as $entry) {
         $list = $this->accessDecider->getUserListForEntry($entry);
         if ($list->count() == 0) {
             throw new \RuntimeException('Entry #' . $entry->id . ' has no access. Share it.');
         }
     }
     foreach ($entries as $entry) {
         if ($entry->password != '') {
             continue;
         }
         echo $entry->id . '... ';
         $this->entryCrypt->encrypt($entry->password, $entry);
         echo ' encrypted!' . "\n";
     }
 }
示例#2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @param EntryCrypt $entryCrypt
  * @return Response
  */
 public function destroy($id, EntryCrypt $entryCrypt)
 {
     $model = Share::findOrFail($id);
     $entry = $model->entry;
     if (!$model->delete()) {
         return Response::json(['flash' => 'Unauthorized.'], 403);
     }
     $entryCrypt->removeInvalidShares($entry);
 }
示例#3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @param EntryCrypt $entryCrypt
  * @return Response
  */
 public function destroy($id, EntryCrypt $entryCrypt)
 {
     $model = UserTeam::findOrFail($id);
     if (!$model->delete()) {
         abort(403);
     }
     $this->getListOfEntries($model)->each(function ($entry) use($entryCrypt) {
         $entryCrypt->removeInvalidShares($entry);
     });
 }
示例#4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @param EntryCrypt $entryCrypt
  * @return Response
  */
 public function destroy($id, EntryCrypt $entryCrypt)
 {
     $model = ProjectTeam::findOrFail($id);
     $project = $model->project;
     if (!$model->delete()) {
         abort(403);
     }
     foreach ($project->keys as $key) {
         $entryCrypt->removeInvalidShares($key);
     }
 }
示例#5
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);
     }
 }
示例#6
0
 /**
  * Get password for Entry
  *
  * @param Entry $model
  * @param HistoryLogger $logger
  * @param EntryCrypt $entryCrypt
  * @return mixed
  */
 public function getPassword(Entry $model, HistoryLogger $logger, EntryCrypt $entryCrypt)
 {
     if (!$model->can_edit) {
         abort(403);
     }
     try {
         $data = $entryCrypt->decrypt($model);
         $logger->log('password', 'Accessed password #' . $model->id . ' (' . $model->project->name . ').', $model->id);
         return Response::json(['password' => strlen($data) > 0 ? $data : ''], 200);
     } catch (\RuntimeException $e) {
         abort(409);
     }
 }