protected function AuthenticationManager::defaultFilter

protected AuthenticationManager::defaultFilter(Request $request, $provider_id)

Default implementation of the provider filter.

Checks whether a provider is allowed as per the _auth option on a route. If the option is not set or if the request did not match any route, only providers from the global provider set are allowed.

If no filter is registered for the given provider id, the default filter is applied.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The incoming request.

string $provider_id: The id of the authentication provider to check access for.

Return value

bool TRUE if provider is allowed, FALSE otherwise.

File

core/lib/Drupal/Core/Authentication/AuthenticationManager.php, line 174

Class

AuthenticationManager
Manager for authentication.

Namespace

Drupal\Core\Authentication

Code

protected function defaultFilter(Request $request, $provider_id) {
  $route = RouteMatch::createFromRequest($request)->getRouteObject();
  $has_auth_option = isset($route) && $route->hasOption('_auth');

  if ($has_auth_option) {
    return in_array($provider_id, $route->getOption('_auth'));
  }
  else {
    return $this->authCollector->isGlobal($provider_id);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Authentication!AuthenticationManager.php/function/AuthenticationManager::defaultFilter/8.1.x