diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php index 9f4c841..30ee524 100644 --- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php +++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php @@ -23,20 +23,6 @@ class AuthenticationManager implements AuthenticationProviderInterface, AuthenticationProviderFilterInterface, AuthenticationProviderChallengeInterface { /** - * List of providers which implement the filter interface. - * - * @var \Drupal\Core\Authentication\AuthenticationProviderFilterInterface[] - */ - protected $filters; - - /** - * List of providers which implement the challenge interface. - * - * @var \Drupal\Core\Authentication\AuthenticationProviderChallengeInterface[] - */ - protected $challengers; - - /** * The authentication provider collector. * * @var \Drupal\Core\Authentication\AuthenticationCollectorInterface @@ -45,18 +31,12 @@ class AuthenticationManager implements AuthenticationProviderInterface, Authenti /** * Creates a new authentication manager instance. + * + * @param \Drupal\Core\Authentication\AuthenticationCollectorInterface $auth_collector + * The authentication provider collector. */ public function __construct(AuthenticationCollectorInterface $auth_collector) { $this->authCollector = $auth_collector; - - foreach ($this->authCollector->getSortedProviders() as $provider_id => $provider) { - if ($provider instanceof AuthenticationProviderFilterInterface) { - $this->filters[$provider_id] = $provider; - } - if ($provider instanceof AuthenticationProviderChallengeInterface) { - $this->challengers[$provider_id] = $provider; - } - } } /** @@ -135,11 +115,9 @@ protected function getProvider(Request $request) { * If no application detects appropriate credentials, then NULL is returned. */ protected function getChallenger(Request $request) { - if (!empty($this->challengers)) { - foreach ($this->authCollector->getSortedProviders() as $provider_id => $provider) { - if (isset($this->challengers[$provider_id]) && !$provider->applies($request) && $this->applyFilter($request, FALSE, $provider_id)) { - return $provider_id; - } + foreach ($this->authCollector->getSortedProviders() as $provider_id => $provider) { + if (($provider instanceof AuthenticationProviderChallengeInterface) && !$provider->applies($request) && $this->applyFilter($request, FALSE, $provider_id)) { + return $provider_id; } } } @@ -161,8 +139,10 @@ protected function getChallenger(Request $request) { * TRUE if provider is allowed, FALSE otherwise. */ protected function applyFilter(Request $request, $authenticated, $provider_id) { - if (isset($this->filters[$provider_id])) { - $result = $this->filters[$provider_id]->appliesToRoutedRequest($request, $authenticated); + $provider = $this->authCollector->getProvider($provider_id); + + if ($provider && ($provider instanceof AuthenticationProviderFilterInterface)) { + $result = $provider->appliesToRoutedRequest($request, $authenticated); } else { $result = $this->defaultFilter($request, $provider_id);