jenkins-bot has submitted this change and it was merged.

Change subject: Remove pre authmanager MW support
......................................................................


Remove pre authmanager MW support

Change-Id: I46712392e48c263bd30b849777caea8e22650d40
---
D OATHAuth.hooks.legacy.php
M OATHAuth.hooks.php
M extension.json
3 files changed, 12 insertions(+), 109 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/OATHAuth.hooks.legacy.php b/OATHAuth.hooks.legacy.php
deleted file mode 100644
index 739f256..0000000
--- a/OATHAuth.hooks.legacy.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-/**
- * Hooks for Extension:OATHAuth
- * @deprecated B/C class for compatibility with pre-AuthManager core
- */
-class OATHAuthLegacyHooks {
-       /**
-        * @param $extraFields array
-        * @return bool
-        */
-       static function ChangePasswordForm( &$extraFields ) {
-               $tokenField = [ 'wpOATHToken', 'oathauth-token', 'password', '' 
];
-               array_push( $extraFields, $tokenField );
-
-               return true;
-       }
-
-       /**
-        * @param $user User
-        * @param $password string
-        * @param $newpassword string
-        * @param &$errorMsg string
-        * @return bool
-        */
-       static function AbortChangePassword( $user, $password, $newpassword, 
&$errorMsg ) {
-               global $wgRequest;
-
-               $token = $wgRequest->getText( 'wpOATHToken' );
-               $oathrepo = OATHAuthHooks::getOATHUserRepository();
-               $oathuser = $oathrepo->findByUser( $user );
-               # Though it's weird to default to true, we only want to deny
-               # users who have two-factor enabled and have validated their
-               # token.
-               $result = true;
-
-               if ( $oathuser->getKey() !== null ) {
-                       // Don't increase pingLimiter, just check for limit 
exceeded.
-                       if ( $user->pingLimiter( 'badoath', 0 ) ) {
-                               $result = 'oathauth-abortlogin-throttled';
-                       } elseif ( !$oathuser->getKey()->verifyToken( $token, 
$oathuser ) ) {
-                               $result = 'oathauth-abortlogin';
-                       }
-               }
-
-               if ( $result === true ) {
-                       return true;
-               } else {
-                       $errorMsg = $result;
-                       return false;
-               }
-       }
-
-       /**
-        * @param $user User
-        * @param $password string
-        * @param &$abort int
-        * @param &$errorMsg string
-        * @return bool
-        */
-       static function AbortLogin( $user, $password, &$abort, &$errorMsg ) {
-               $context = RequestContext::getMain();
-               $request = $context->getRequest();
-               $output = $context->getOutput();
-
-               $oathrepo = OATHAuthHooks::getOATHUserRepository();
-               $oathuser = $oathrepo->findByUser( $user );
-               $uid = CentralIdLookup::factory()->centralIdFromLocalUser( 
$user );
-
-               if ( $oathuser->getKey() !== null && !$request->getCheck( 
'token' ) ) {
-                       $encData = OATHAuthUtils::encryptSessionData(
-                               $request->getValues(),
-                               $uid
-                       );
-                       $request->setSessionData( 'oath_login', $encData );
-                       $request->setSessionData( 'oath_uid', $uid );
-                       $output->redirect( SpecialPage::getTitleFor( 'OATH' 
)->getFullURL( '', false, PROTO_CURRENT ) );
-                       return false;
-               } else {
-                       return true;
-               }
-       }
-}
diff --git a/OATHAuth.hooks.php b/OATHAuth.hooks.php
index 39f269b..e5f5c05 100644
--- a/OATHAuth.hooks.php
+++ b/OATHAuth.hooks.php
@@ -29,29 +29,6 @@
        }
 
        /**
-        * Register hooks which depend on MediaWiki core version
-        */
-       public static function onRegistration() {
-               global $wgDisableAuthManager, $wgAuthManagerAutoConfig;
-
-               if ( !$wgDisableAuthManager && class_exists( AuthManager::class 
) ) {
-                       $wgAuthManagerAutoConfig['secondaryauth'] += [
-                               TOTPSecondaryAuthenticationProvider::class => [
-                                       'class' => 
TOTPSecondaryAuthenticationProvider::class,
-                                       // after non-interactive providers but 
before the ones
-                                       // that run after a successful 
authentication
-                                       'sort' => 50,
-                               ]
-                       ];
-                       Hooks::register( 'AuthChangeFormFields', 
'OATHAuthHooks::onAuthChangeFormFields' );
-               } else {
-                       Hooks::register( 'AbortChangePassword', 
'OATHAuthLegacyHooks::AbortChangePassword' );
-                       Hooks::register( 'AbortLogin', 
'OATHAuthLegacyHooks::AbortLogin' );
-                       Hooks::register( 'ChangePasswordForm', 
'OATHAuthLegacyHooks::ChangePasswordForm' );
-               }
-       }
-
-       /**
         * @param AuthenticationRequest[] $requests
         * @param array $fieldInfo Field information array (union of the
         *    AuthenticationRequest::getFieldInfo() responses).
diff --git a/extension.json b/extension.json
index 2b0fa3e..3b9a7a1 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "OATHAuth",
-       "version": "0.2.1",
+       "version": "0.2.2",
        "author": "Ryan Lane",
        "url": "https://www.mediawiki.org/wiki/Extension:OATHAuth";,
        "descriptionmsg": "oathauth-desc",
@@ -10,7 +10,6 @@
                "ApiOATHValidate": "api/ApiOATHValidate.php",
                "ApiQueryOATH": "api/ApiQueryOATH.php",
                "OATHAuthHooks": "OATHAuth.hooks.php",
-               "OATHAuthLegacyHooks": "OATHAuth.hooks.legacy.php",
                "OATHAuthKey": "OATHAuthKey.php",
                "OATHAuthUtils": "OATHAuthUtils.php",
                "OATHUserRepository": "OATHUserRepository.php",
@@ -26,11 +25,21 @@
                "TOTPAuthenticationRequest": 
"auth/TOTPAuthenticationRequest.php",
                "TOTPSecondaryAuthenticationProvider": 
"auth/TOTPSecondaryAuthenticationProvider.php"
        },
+       "AuthManagerAutoConfig": {
+               "secondaryauth": {
+                       "TOTPSecondaryAuthenticationProvider":{
+                               "class": "TOTPSecondaryAuthenticationProvider",
+                               "sort": 50
+                       }
+               }
+       },
        "ExtensionMessagesFiles": {
                "OATHAuthAlias": "OATHAuth.alias.php"
        },
-       "callback": "OATHAuthHooks::onRegistration",
        "Hooks": {
+               "AuthChangeFormFields": [
+                       "OATHAuthHooks::onAuthChangeFormFields"
+               ],
                "TwoFactorIsEnabled": [
                        "OATHAuthHooks::onTwoFactorIsEnabled"
                ],

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I46712392e48c263bd30b849777caea8e22650d40
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/OATHAuth
Gerrit-Branch: master
Gerrit-Owner: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to