@param Request $request

@throws AuthenticationExceptionInterface
427349
public function login(Request $request)
    {
        $data = $request->getParsedBody();
        $this->checkingRequirements($data);

        /** @var UserPasswordInterface $user */
        if (null === $user = $this->findByUsername($data['username'])) {
            $this->logger->warning(
                'security.authentication.form: user not found with criteria {criteria}',
                ['criteria' => $this->getCriteriaAsSting(['username' => $data['username']])]
            );

            throw UserNotFoundException::create(['username' => $data['username']]);
        }

        if (!$this->passwordManager->verify($data['password'], $user->getPassword())) {
            $this->logger->warning(
                'security.authentication.form: invalid password for user with criteria {criteria}',
                ['criteria' => $this->getCriteriaAsSting(['username' => $data['username']])]
            );

            throw InvalidPasswordException::create(['username' => $data['username']]);
        }

        $this->logger->info(
            'security.authentication.form: login successful for user with id {id}', ['id' => $user->getId()]
        );

        $this->session->set($request, self::USER_KEY, $user->getId());
    }
755408
protected function unauthenticated($request, AuthenticationException $exception)
    {
        if ($request->expectsJson()) {
            return response()->json(['error' => 'Unauthenticated.'], 401);
        }

        return redirect()->route('soda.login');
    }
732918
public function handle($request, Closure $next, $strategy = null, $sessions = true)
    {
        if ( ! ($user = $this->manager->login($strategy, $request))) {
            throw new AuthenticationException('Unauthenticated.');
        };

        if($sessions) {
            Auth::login($user);
        } else {
            Auth::setUser($user);
        }

        return $next($request);
    }
255657
private function setTrustedProxyIpAddressesToTheCallingIp(Request $request)
    {
        $request->setTrustedProxies([$request->server->get('REMOTE_ADDR')], $this->getTrustedHeaderNames());
    }
574634
public function execute($request)
    {
        $logger = $GLOBALS['logger'];

        try {
            parent::execute($request);
        } catch(AuthenticationException $ex) {
            $logger->error('Unauthorized attempt to access resource, being redirected to home page', array($ex->getMessage()));
            $this->_handleUnauthenticatedAccess();
            $this->_response->send();
        }
    }
1210818
protected function authorize(Request $request)
    {
        $authorizer = $this->resolveAuthorizer($request);

        if ($authorizer) {
            $authorizer->authorize($this->getSubject());
        }
    }
1266171
public function getAuthenticatedUser(Request $request)
    {
        if (!$this->checkForUserIdWithinSession($request)) {
            $this->logger->info('security.authentication.form: not authenticated');

            return null;
        }

        $id = $this->getUserIdFromSession($request);

        if (null === $user = $this->find($id)) {
            $this->logger->warning('security.authentication.form: user with id {id} is not resolvable', ['id' => $id]);
            $this->session->remove($request, self::USER_KEY);

            return null;
        }

        $this->logger->info('security.authentication.form: authenticated user with id {id}', ['id' => $id]);

        return $user;
    }
231980
protected function checkAuthentication(Request $request)
    {
        if (!$request->hasPreviousSession()) {
            return;
        }

        $session = $request->getSession();

        if ($session->has('token')) {
            $token = $session->get('token');
            $this->tokenStorage->setToken($token);
        }
    }
554244
public function setRequest( Request $request )
	{
		$this->request = $request;

		$this->cachedRoot = null;
		$this->cachedSchema = null;
	}
992895
protected function authRedirect(RequestInterface $request)
    {
        unset($request);
        // Test if authentication is required.
        if ($this->authRequired() === false) {
            return;
        }

        // Test if user is authorized to access this controller
        if ($this->isAuthorized() === true) {
            return;
        }

        header('HTTP/1.0 403 Forbidden');
        exit;
    }
219089
private function authBasic(Request $request) {
		$user = $this->findUser($request->getUser());
		if ($user !== null && $this->verifyUser($user, $request->getPassword())) {
			$session = $this->findSession($user);
			if ($session === null) {
				$session = $this->createSession($user);
			}
			$this->authenticated = true;

			return $session;
		}
		return null;
	}
1241692
protected function authenticate($request) : bool
  {
    $bearer = substr($request->header('Authorization'), 6);
    $token  = explode(' ', $bearer)[1];

    try {
      $payLoad = $this->validateToken($token);
    }
    catch (TokenValidatorException $e) {
      $this->fails($e);
      cancel();
    }

    $userid   = $payLoad['iss'];
    $provider = $payLoad['pro'];

    $model = config('auth.provider.' . $provider . '.model');

    Auth::grant($model::where('id', $userid)->firstOrFail());

    return true;
  }
102832
public function checkForToken(Request $request)
    {
        if (! $this->auth->parser()->setRequest($request)->hasToken()) {
            throw new UnauthorizedHttpException('jwTauth', 'Token not provided');
        }
    }
792349
public function authenticate(RequestInterface $request)
    {
        $token = $this->token();

        if (!$token && !$this->findMatchingArea($request)) {
            return $this;
        }

        if (!$token) {
            throw new AuthenticationException('Unable to authenticate, token is missing');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsToken($token)) {
                continue;
            }

            if (!$provider->authenticate($token)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Token could not be authenticated in provider "%s", destroying token', get_class($provider)));
            }

            $this->user = $provider->get($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Missing provider supporting token "%s", destroying token', get_class($token)));
    }
144734
public function prepareForAuthentication(Request $request)
    {
        $e = $this->getEvent();
        $e->setRequest($request);

        $e->setName('authenticate.pre');
        $this->getEventManager()->triggerEvent($e);

        $e->setName('authenticate');
        $result = $this->getEventManager()->triggerEventUntil(function ($test) {
            return ($test instanceof Response);
        }, $e);

        if ($result->stopped()) {
            if ($result->last() instanceof Response) {
                return $result->last();
            }

            throw new Exception\AuthenticationEventException(
                sprintf(
                    'Auth event was stopped without a response. Got "%s" instead',
                    is_object($result->last()) ? get_class($result->last()) : gettype($result->last())
                )
            );
        }

        if ($e->getIdentity()) {
            $e->setName('authenticate.success');
            $this->getEventManager()->triggerEvent($e);
            return true;
        }

        $e->setName('authenticate.fail');
        $this->getEventManager()->triggerEvent($e);

        return false;
    }
302394
public function authenticate(Request $request)
    {
        if ($request->hasSession()) {
            $request->session()->reflash();
        }

        return Broadcast::auth($request);
    }
1243295
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
    {
        $errorMessage = 'Authentication Failed';
        $responseCode = Response::HTTP_BAD_REQUEST;

        if ($exception instanceof TokenExpiredException) {
            $errorMessage = 'Token expired';
            $responseCode = Response::HTTP_UNAUTHORIZED;
        } elseif ($exception instanceof AccountStatusException) {
            $errorMessage = 'Account disabled';
            $responseCode = Response::HTTP_FORBIDDEN;
        }

        return new JsonResponse(['error' => $errorMessage], $responseCode);
    }