From 3e970169f6caf5b53ca8017341256b84d56fe892 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 1 Jun 2016 14:16:49 -0400 Subject: [PATCH] Make AuthManager::getAuthenticationProvider() public I found a need in CentralAuth to check that CentralAuthPrimaryAuthenticationProvider is actually in use, so I'm exposing this. Change-Id: I40bd3dc4d05db0c3a34b01f550a9a9a1ded8fc61 --- includes/auth/AuthManager.php | 59 ++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php index 69f51b899f..8cca3a5f19 100644 --- a/includes/auth/AuthManager.php +++ b/includes/auth/AuthManager.php @@ -2102,6 +2102,37 @@ class AuthManager implements LoggerAwareInterface { return true; } + /** + * Get a provider by ID + * @note This is public so extensions can check whether their own provider + * is installed and so they can read its configuration if necessary. + * Other uses are not recommended. + * @param string $id + * @return AuthenticationProvider|null + */ + public function getAuthenticationProvider( $id ) { + // Fast version + if ( isset( $this->allAuthenticationProviders[$id] ) ) { + return $this->allAuthenticationProviders[$id]; + } + + // Slow version: instantiate each kind and check + $providers = $this->getPrimaryAuthenticationProviders(); + if ( isset( $providers[$id] ) ) { + return $providers[$id]; + } + $providers = $this->getSecondaryAuthenticationProviders(); + if ( isset( $providers[$id] ) ) { + return $providers[$id]; + } + $providers = $this->getPreAuthenticationProviders(); + if ( isset( $providers[$id] ) ) { + return $providers[$id]; + } + + return null; + } + /**@}*/ /** @@ -2251,34 +2282,6 @@ class AuthManager implements LoggerAwareInterface { return $this->secondaryAuthenticationProviders; } - /** - * Get a provider by ID - * @param string $id - * @return AuthenticationProvider|null - */ - protected function getAuthenticationProvider( $id ) { - // Fast version - if ( isset( $this->allAuthenticationProviders[$id] ) ) { - return $this->allAuthenticationProviders[$id]; - } - - // Slow version: instantiate each kind and check - $providers = $this->getPrimaryAuthenticationProviders(); - if ( isset( $providers[$id] ) ) { - return $providers[$id]; - } - $providers = $this->getSecondaryAuthenticationProviders(); - if ( isset( $providers[$id] ) ) { - return $providers[$id]; - } - $providers = $this->getPreAuthenticationProviders(); - if ( isset( $providers[$id] ) ) { - return $providers[$id]; - } - - return null; - } - /** * @param User $user * @param bool|null $remember -- 2.20.1