Get guards passed as parameters to `auth` middleware.

@param  \Illuminate\Http\Request $request
@return array
493933
public static function getAuthGuards(Request $request)
    {
        $middlewares = $request->route()->middleware();

        $guards = [];
        foreach ($middlewares as $middleware) {
            if (Str::startsWith($middleware, 'auth')) {
                $explodedGuards = explode(',', Str::after($middleware, ':'));
                $guards = array_unique(array_merge($guards, $explodedGuards));
            }
        }

        return $guards;
    }
45958
protected function getOptions(Request $request)
    {
        $configs = $this->getCorsConfigs();
        $uri = $request->getPathInfo() ?: '/';

        /** @var CorsConfig $bestMatch */
        $bestMatch = null;
        foreach ($configs as $config) {
            $path = $config->path;
            if ($request->is($path) || (Str::startsWith($path, '^') && preg_match('{' . $path . '}i', $uri))) {
                if ($bestMatch) {
                    // simple compare path lengths for accuracy
                    if (strlen($path) > strlen($bestMatch->path)) {
                        $bestMatch = $config;
                    }
                } else {
                    $bestMatch = $config;
                }
            }
        }

        if ($bestMatch) {
            return [
                "allowedOrigins"      => explode(',', $bestMatch->origin),
                "allowedHeaders"      => explode(',', $bestMatch->header),
                "exposedHeaders"      => explode(',', $bestMatch->exposed_header),
                "allowedMethods"      => $bestMatch->method,
                "maxAge"              => $bestMatch->max_age,
                "supportsCredentials" => $bestMatch->supports_credentials,
            ];
        }

        return [];
    }
249774
public function getOptions(Request $request)
    {
        $routes = [];

        foreach ($this->routes as $route) {
            if ($route->matchesPattern($request)) {
                $routes[] = $route;
            }
        }

        return $routes;
    }
27201
protected function parseIncomingRequest($request)
    {
        if (! $request) {
            $request = LumenRequest::capture();
        }

        $this->instance(Request::class, $this->prepareRequest($request));

        return [$request->getMethod(), '/'.\trim($request->getPathInfo(), '/')];
    }
1097450
public function getCredentials(Request $request)
    {
        $token = !empty($request->headers->get(self::AUTHORIZATION_HEADER)) ?
            $request->headers->get(self::AUTHORIZATION_HEADER) :
            $request->cookies->get(AuthResponseService::AUTH_COOKIE);

        return new CredentialTokenModel(str_replace(self::BEARER, '', $token));
    }
957803
public function handle($request, Closure $next, $guard = null)
    {
        if (auth()->guard($guard)->check()) {
            return intend([
                'url' => route($request->route('accessarea').'.home'),
                'with' => ['success' => trans('cortex/foundation::messages.already_authenticated')],
            ]);
        }

        return $next($request);
    }
556327
protected function getFiltersFromRequest(Request $request)
    {
        return $this->extractValues($this->getValuesFromRequest($request), $this->getFilterPrefix());
    }
1309533
protected function authenticate($request, array $guards)
    {
        if (empty($guards)) {
            $guards = [null];
        }

        foreach ($guards as $guard) {
            if ($this->auth->guard($guard)->check()) {
                return $this->auth->shouldUse($guard);
            }
        }

        throw new AuthenticationException(
            'Unauthenticated.', $guards, $this->redirectTo($request)
        );
    }
917994
public function flush(Request $request)
    {
        $request->user($this->getGuard())->sessions()->delete();

        return intend([
            'back' => true,
            'with' => ['warning' => trans('cortex/auth::messages.auth.session.flushed')],
        ]);
    }
1148175
public function authenticate(Request $request)
    {
        return $request->get('username') === $this->username
            && password_verify($request->get('password'), $this->password);
    }
486870
public function loginLinkAction(Request $request)
    {
        $casLogin = $request->getSession()->get('CAS_AUTHENTICATION_USER_ID');
        if (empty($casLogin)) {
            return $this->redirectToRoute('claro_index');
        }
        $request->getSession()->set('LOGGED_VIA_CAS', true);

        return [];
    }
497632
protected function getVariables(Request $request)
    {
        $token  = $this->securityContext->getToken();
        $user   = null;
        $roles  = [];

        if ($token instanceof TokenInterface) {
            $user = $token->getUser();

            if (null !== $this->roleHierarchy) {
                $roles = $this->roleHierarchy->getReachableRoles($token->getRoles());
            } else {
                $roles = $token->getRoles();
            }
        }

        $variables = array(
            'token' => $token,
            'user'  => $user,
            // we removed "object" and "request"
            'roles' => array_map(function (RoleInterface $role) { return $role->getRole(); }, $roles),
            'trust_resolver' => $this->trustResolver,
            'security_context' => $this->securityContext,
        );

        // controller variables should also be accessible: repository, entity...
        return array_merge($request->attributes->all(), $variables);
    }
203369
public function getAuthenticatedUser(Request $request)
    {
        foreach ($this->authentications as $authentication) {
            if (null !== $user = $authentication->getAuthenticatedUser($request)) {
                return $user;
            }
        }

        return null;
    }
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;
    }
132836
protected function extractErrorFromRequest(Request $request)
    {
        // check for error
        $error_code = $request->get('error');
        $error_description = null;
        if ($error_code) {
            if ($error_code == 'access_denied') {
                $error_description = 'Access was denied.';
            } else {
                $error_description = $request->get('error_description');
            }
            return [$error_code, $error_description];
        }

        // no error
        return [null, null];
    }
1245700
public function supportRequestToken(Request $request)
    {
        $clientExist = $request->getUser() && $request->getPassword();
        $oauthParams = $request->get('grant_type') === 'client_credentials';

        return $oauthParams && $clientExist;
    }
1222718
public function verifyRequest($request)
    {
        $this->getVersion($request);
        $consumer = $this->getConsumer($request);
        $token = $this->getToken($request, $consumer, "access");
        $this->checkSignature($request, $consumer, $token);
        return array($consumer, $token);
    }