Robert Vogel has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394969 )

Change subject: Added PluggableAuth::authorize
......................................................................

Added PluggableAuth::authorize

This way a PluggableAuth-Plugin can implement authorozation without
having to bind to "PluggableAuthUserAuthorization" hook.

Change-Id: I004ee621375442ca323b6d4316a3a2d8b1292b68
---
M includes/PluggableAuth.php
M includes/PluggableAuthLogin.php
2 files changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PluggableAuth 
refs/changes/69/394969/1

diff --git a/includes/PluggableAuth.php b/includes/PluggableAuth.php
index b85d8d1..06cc2e1 100644
--- a/includes/PluggableAuth.php
+++ b/includes/PluggableAuth.php
@@ -32,6 +32,7 @@
 
        /**
         * @since 2.0
+        * @return PluggableAuth
         */
        public static function singleton() {
                if ( !is_null( self::$instance ) ) {
@@ -46,4 +47,13 @@
                wfDebug( 'Could not get authentication plugin instance.' );
                return false;
        }
+
+       /**
+        * Can be overridden by subclasses
+        * @param User $user
+        * @return boolean
+        */
+       public function authorize( $user ) {
+               return true;
+       }
 }
diff --git a/includes/PluggableAuthLogin.php b/includes/PluggableAuthLogin.php
index 8cf5f94..003832e 100644
--- a/includes/PluggableAuthLogin.php
+++ b/includes/PluggableAuthLogin.php
@@ -21,6 +21,10 @@
                $authManager = AuthManager::singleton();
                $user = $this->getUser();
                $pluggableauth = PluggableAuth::singleton();
+               $id = null;
+               $username = '';
+               $realname = '';
+               $email = '';
                $error = null;
                if ( $pluggableauth ) {
                        if ( $pluggableauth->authenticate( $id, $username, 
$realname, $email,
@@ -39,7 +43,7 @@
                                        wfDebug( 'Authenticated existing user: 
' . $user->mName );
                                }
                                Hooks::run( 'PluggableAuthPopulateGroups', [ 
$user ] );
-                               $authorized = true;
+                               $authorized = $pluggableauth->authorize( $user 
);
                                Hooks::run( 'PluggableAuthUserAuthorization', [ 
$user, &$authorized ] );
                                if ( $authorized ) {
                                        
$authManager->setAuthenticationSessionData(

-- 
To view, visit https://gerrit.wikimedia.org/r/394969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I004ee621375442ca323b6d4316a3a2d8b1292b68
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PluggableAuth
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to