Make AuthManager::getAuthenticationProvider() public
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 1 Jun 2016 18:16:49 +0000 (14:16 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 1 Jun 2016 18:16:49 +0000 (14:16 -0400)
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

index 69f51b8..8cca3a5 100644 (file)
@@ -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