Reject authentication data change when there are warnings
authorGergő Tisza <gtisza@wikimedia.org>
Tue, 7 Jun 2016 16:15:12 +0000 (16:15 +0000)
committerAnomie <bjorsch@wikimedia.org>
Tue, 7 Jun 2016 17:24:18 +0000 (17:24 +0000)
AuthManager uses a status which is OK but not good for authentication
data which is discouraged but still accepted for authentication.
Users should not be allowed to change credentials into such invalid state.
This change brings the web logic and the AuthPlugin fallback in sync with
the API which already used the stricter check.

Change-Id: I4ff54fcc901f6fe11f15ed60fc1a3d8753de9f6c

includes/Preferences.php
includes/auth/AuthManagerAuthPlugin.php
includes/specialpage/AuthManagerSpecialPage.php
includes/user/User.php

index 9a55ae3..3083a8d 100644 (file)
@@ -296,7 +296,7 @@ class Preferences {
 
                $allowPasswordChange = $wgDisableAuthManager ? $wgAuth->allowPasswordChange()
                        : AuthManager::singleton()->allowsAuthenticationDataChange(
-                               new PasswordAuthenticationRequest(), false );
+                               new PasswordAuthenticationRequest(), false )->isGood();
                if ( $canEditPrivateInfo && $allowPasswordChange ) {
                        $link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ),
                                $context->msg( 'prefs-resetpass' )->escaped(), [],
index bf1e021..8d85b44 100644 (file)
@@ -131,7 +131,7 @@ class AuthManagerAuthPlugin extends \AuthPlugin {
                $reqs = AuthenticationRequest::loadRequestsFromSubmission( $reqs, $data );
                foreach ( $reqs as $req ) {
                        $status = AuthManager::singleton()->allowsAuthenticationDataChange( $req );
-                       if ( !$status->isOk() ) {
+                       if ( !$status->isGood() ) {
                                $this->logger->info( __METHOD__ . ': Password change rejected: {reason}', [
                                        'username' => $data['username'],
                                        'reason' => $status->getWikiText( null, null, 'en' ),
index 7866c12..41380f0 100644 (file)
@@ -375,7 +375,7 @@ abstract class AuthManagerSpecialPage extends SpecialPage {
                                $req = reset( $requests );
                                $status = $authManager->allowsAuthenticationDataChange( $req );
                                Hooks::run( 'ChangeAuthenticationDataAudit', [ $req, $status ] );
-                               if ( !$status->isOK() ) {
+                               if ( !$status->isGood() ) {
                                        return AuthenticationResponse::newFail( $status->getMessage() );
                                }
                                $authManager->changeAuthenticationData( $req );
index 9e50f36..8ecf468 100644 (file)
@@ -2569,7 +2569,7 @@ class User implements IDBAccessObject {
                        $reqs = AuthenticationRequest::loadRequestsFromSubmission( $reqs, $data );
                        foreach ( $reqs as $req ) {
                                $status = $manager->allowsAuthenticationDataChange( $req );
-                               if ( !$status->isOk() ) {
+                               if ( !$status->isGood() ) {
                                        \MediaWiki\Logger\LoggerFactory::getInstance( 'authentication' )
                                                ->info( __METHOD__ . ': Password change rejected: ' . $status->getWikiText() );
                                        return false;