This should likely be redone as a PrimaryAuthenticationProvider, hopefully without the requirement of patching MediaWiki core.
The code for logging in to the remote wiki may also need updating, since API action=login is no longer guaranteed to continue working for the main account password under AuthManager.