Пример #1
0
 public function findByTag(Request $request)
 {
     $tags = $request->get('tags', []);
     if (sizeof($tags) == 0) {
         abort(404);
     }
     /** @var \Illuminate\Database\Eloquent\Builder $q */
     $q = Entry::where('project_id', $request->get('project', 0))->select("entry.*");
     foreach ($tags as $i => $tag) {
         $q->join("entry_tag as tag_{$i}", "tag_{$i}.entry_id", "=", "entry.id");
         $q->where("tag_{$i}.name", strtoupper($tag));
     }
     $key = $q->get();
     if ($key->count() == 0) {
         abort(404);
     }
     if ($key->count() > 1) {
         abort(422);
     }
     $key = $key[0];
     if ($entry = $this->getKey($request, $key)) {
         return $entry;
     }
     return new JsonResponse(['message' => 'No suitable key found.'], 404);
 }
Пример #2
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));
 }
Пример #3
0
 /**
  * Get list of available passwords by domain
  *
  * @param Request $request
  * @return mixed
  */
 public function getByDomain(Request $request)
 {
     $domain = $request->get('domain', null);
     if (is_null($domain)) {
         return [];
     }
     return Entry::where('url', 'like', '%' . $domain . '%')->with('tags')->whereHas('keyShares', function ($q) {
         $q->where('user_id', Auth::user()->id);
     })->get();
 }