/**
  * Performs authentication if cookie is present.
  *
  * @param GetResponseEvent $event
  *
  * @return bool|\ONGR\SettingsBundle\Security\Authentication\Token\SessionlessToken
  */
 private function authenticateCookie(GetResponseEvent $event)
 {
     $cookieData = $this->authCookie->getValue();
     if ($cookieData !== null) {
         if (!$this->authCookieService->validateCookie($cookieData)) {
             return false;
         }
         $token = new SessionlessToken($cookieData['username'], $cookieData['expiration'], $event->getRequest()->getClientIp(), $cookieData['signature']);
         try {
             $authenticatedToken = $this->authenticationProvider->authenticate($token);
         } catch (AuthenticationException $e) {
             return false;
         }
         return $authenticatedToken;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Test cookie returns not dirty status, when not modified.
  */
 public function testNotDirtyWhenLoaded()
 {
     $cookie = new JsonCookie('test');
     $cookie->load(json_encode(['test']));
     $this->assertFalse($cookie->isDirty());
 }