コード例 #1
0
ファイル: DeployKeyController.php プロジェクト: vaidasm/vault
 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;
 }
コード例 #2
0
ファイル: ApiKeyMiddleware.php プロジェクト: vaidasm/vault
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, \Closure $next)
 {
     try {
         $userAndKey = $this->key->extractKeyAndUser($request);
         if ($userAndKey) {
             /** @var User $user */
             $user = $userAndKey['user'];
             if ($user->isDisabled()) {
                 abort(403, 'User is disabled');
             }
             $this->manager->setUser($user);
         }
         return $next($request);
     } catch (InvalidAuthException $e) {
         abort(401, $e->getMessage());
     }
     abort(401, 'User could not be found.');
 }