/** * @param string $bundle * @param string $controller * @param string $action * * @return bool */ public function isIgnorablePath($bundle, $controller, $action) { $ignorable = $this->authConfig->getIgnorable(); foreach ($ignorable as $ignore) { if (($bundle === $ignore['bundle'] || $ignore['bundle'] === AuthConstants::AUTHORIZATION_WILDCARD) && ($controller === $ignore['controller'] || $ignore['controller'] === AuthConstants::AUTHORIZATION_WILDCARD) && ($action === $ignore['action'] || $ignore['action'] === AuthConstants::AUTHORIZATION_WILDCARD)) { return true; } } return false; }
/** * @param string $token * * @return bool */ public function isValidToken($token) { $resetPasswordEntity = $this->authQueryContainer->queryForActiveCode($token)->findOne(); if (empty($resetPasswordEntity)) { return false; } $expiresInSeconds = $this->authConfig->getPasswordTokenExpirationInSeconds(); $expiresAt = $resetPasswordEntity->getCreatedAt(); $expiresAt->add(new \DateInterval('PT' . $expiresInSeconds . 'S')); $currentDateTime = new \DateTime(); if ($currentDateTime > $expiresAt) { $resetPasswordEntity->setStatus(SpyResetPasswordTableMap::COL_STATUS_EXPIRED); $resetPasswordEntity->save(); return false; } return true; }
/** * @return void */ public function testDoLoginWithToken() { $settings = new AuthConfig(); $token = new StaticToken(); $credentials = $settings->getUsersCredentials(); foreach ($credentials as $username => $credential) { $token->setRawToken($credential['token']); $hash = $token->generate(); $isAllowed = $this->authFacade->isAuthenticated($hash); $this->assertTrue($isAllowed); } }