Beispiel #1
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->config->get('u2f.enable')) {
         return $next($request);
     }
     if (!$this->u2f->check()) {
         if (Auth::guest()) {
             throw new HttpException(401, 'You need to log in before an u2f authentication');
         }
         if (U2fKey::where('user_id', '=', Auth::user()->id)->count() === 0 && $this->config->get('u2f.byPassUserWithoutKey')) {
             return $next($request);
         }
         return redirect()->guest('u2f/auth');
     }
     return $next($request);
 }
Beispiel #2
0
 /**
  * @author LAHAXE Arnaud
  *
  * @param \App\User $user
  * @param           $authData
  * @param           $keyData
  *
  * @return bool
  */
 public function doAuthenticate(User $user, $authData, $keyData)
 {
     $reg = $this->u2f->doAuthenticate($authData, U2fKey::where('user_id', $user->id)->get()->all(), $keyData);
     $U2fKey = U2fKey::where(['user_id' => $user->id, 'publicKey' => $reg->publicKey])->first();
     if (is_null($U2fKey)) {
         return false;
     }
     $U2fKey->counter = $reg->counter;
     $U2fKey->save();
     $this->session->set($this->config->get('u2f.sessionU2fName'), true);
     return $U2fKey;
 }