diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php index 6b2ac51..3d793f7 100644 --- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php +++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php @@ -67,6 +67,19 @@ class AuthenticationManager implements AuthenticationProviderInterface, Authenti protected $globalProviders; /** + * Constructs an authentication manager. + * + * @todo: Revisit service construction. Especially write a custom compiler + * pass which is capable of collecting, sorting and injecting all providers + * (including global/vs non global), filters and challengers on compile time. + * + * @see https://www.drupal.org/node/2432585 + */ + public function __construct($global_providers = ['cookie' => TRUE]) { + $this->globalProviders = $global_providers; + } + + /** * Adds a provider to the array of registered providers. * * @param \Drupal\Core\Authentication\AuthenticationProviderInterface $provider @@ -91,9 +104,6 @@ public function addProvider(AuthenticationProviderInterface $provider, $id, $pri if ($provider instanceof AuthenticationProviderChallengeInterface) { $this->challengers[$id] = $provider; } - if ($id === 'cookie') { - $this->globalProviders[$id] = $provider; - } } /** @@ -239,6 +249,9 @@ protected function defaultFilter(Request $request, $authenticated, $provider_id) /** * Returns the sorted array of authentication providers. * + * @todo: Replace with a list of providers sorted during compile time. + * @see https://www.drupal.org/node/2432585 + * * @return array * An array of authentication provider objects. */