Jump to content
MediaWiki

Extension talk:Auth remoteuser

Add topic
From mediawiki.org
(Redirected from Extension talk:AutomaticREMOTE USER)
Latest comment: 8 months ago by ~2025-31929-76 in topic User Accounts From Another CMS
Archives

$hookContainer must not be accessed before initialization

[edit ]
Latest comment: 1 year ago 7 comments4 people in discussion

MediaWiki version 1.43.1

Extension package: Auth_remoteuser-REL1_43-c985d52.tar.gz

OS: Ubuntu 22.04

Webserver: Apache 2.4.52

We are attempting to upgrade from Mediawiki 1.39.11 LTS to Mediawiki 1.43.1. The Auth_remoteuser extension is working correctly under version 1.39.11. However, when implementing MW 1.43.1 and the latest stable release package of the Auth_remoteuser extension, the following error is generated during a php php.run rebuildall.php. Also, the wiki will not load without display the same error There have been no changes to the LocalSettings.php, just the software upgrade to the new LTS. . If Auth_remoteuser is commented out, the wiki launches correctly, but kerberos authentication based on the remote user credentials is no longer possible. Any possible suggestions to correct this would be greatly appreciated! Thank you.


** Rebuilding links tables -- this can take a long time. It should be safe to abort via ctrl+C if you get bored.

Refreshing links from pages...

[f0f9dfc903d97501c8b9881c] [no req] Error: Typed property MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider::$hookContainer must not be accessed before initialization

Backtrace:

from /var/www/html/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(247)

#0 /var/www/html/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(205): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider->setUserNameReplaceFilter()

#1 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory.php(240): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider->__construct()

#2 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory.php(149): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec()

#3 /var/www/html/includes/session/SessionManager.php(482): Wikimedia\ObjectFactory\ObjectFactory->createObject()

#4 /var/www/html/includes/session/SessionManager.php(541): MediaWiki\Session\SessionManager->getProviders()

#5 /var/www/html/includes/session/SessionManager.php(248): MediaWiki\Session\SessionManager->getSessionInfoForRequest()

#6 /var/www/html/includes/Request/WebRequest.php(867): MediaWiki\Session\SessionManager->getSessionForRequest()

#7 /var/www/html/includes/user/User.php(1079): MediaWiki\Request\WebRequest->getSession()

#8 /var/www/html/includes/user/User.php(435): MediaWiki\User\User->loadFromSession()

#9 /var/www/html/includes/user/User.php(1582): MediaWiki\User\User->load()

#10 /var/www/html/includes/user/Options/UserOptionsManager.php(607): MediaWiki\User\User->getName()

#11 /var/www/html/includes/user/Options/UserOptionsManager.php(262): MediaWiki\User\Options\UserOptionsManager->getCacheKey()

#12 /var/www/html/extensions/Math/src/Hooks.php(107): MediaWiki\User\Options\UserOptionsManager->setOption()

#13 /var/www/html/includes/HookContainer/HookContainer.php(159): MediaWiki\Extension\Math\Hooks->onMaintenanceRefreshLinksInit()

#14 /var/www/html/includes/HookContainer/HookRunner.php(2512): MediaWiki\HookContainer\HookContainer->run()

#15 /var/www/html/maintenance/refreshLinks.php(140): MediaWiki\HookContainer\HookRunner->onMaintenanceRefreshLinksInit()

#16 /var/www/html/maintenance/refreshLinks.php(121): RefreshLinks->doRefreshLinks()

#17 /var/www/html/maintenance/rebuildall.php(62): RefreshLinks->execute()

#18 /var/www/html/maintenance/includes/MaintenanceRunner.php(703): RebuildAll->execute()

#19 /var/www/html/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()

#20 {main} 11L3290 (talk) 17:08, 18 April 2025 (UTC) Reply

What was your resolution? I am seeing the same issue. I have updated all of my extensions and cant seem to figure this out. Gcoltharp (talk) 15:52, 9 May 2025 (UTC) Reply
No resolution as yet. Any of the previous variable configurations that worked in 2.1.1 (10e9302) which is compatible with 1.39 LTS is throwing the error.
So, for example, for 2.1.1 of Auth_remoteuser this worked. $wgAuthRemoteuserDomain = "xyz.com";
But for the latest release of the extension, it's throwing the error if this value is preset. Comment this, and entries like it from LocalSettings.php, then the error goes away. However, even though the user is pulled from the client connection, it's not being passed for Kerberos authentication by subsequent extensions, which does work with 2.1.1 for 1.39LTS.
I've tested this using the same Apache configurations for both 1.39 LTS and 1.43.1. So, no resolution as yet. 11L3290 (talk) 15:44, 12 May 2025 (UTC) Reply
// I have the same problem when migrating from version 1.39 to wiki version 1.43. I installed the latest version of the extension through git to integrate with Kerberos and the GSSAPI module in Apache 2.4. However, it does not integrate.
// I followed the documentation and it displays the following error.
[aC44RVC1hcl54NDRb3FT6wAAAME] /wiki/index.php?title=P%C3%A1gina_principal Error: Typed property MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider::$hookContainer must not be accessed before initialization
Backtrace:
from /var/www/html/wiki/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(248)
  1. 0 /var/www/html/wiki/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(114): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider->setUserNameReplaceFilter()
  2. 1 /var/www/html/wiki/vendor/wikimedia/object-factory/src/ObjectFactory.php(240): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider->__construct()
  3. 2 /var/www/html/wiki/vendor/wikimedia/object-factory/src/ObjectFactory.php(149): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec()
  4. 3 /var/www/html/wiki/includes/session/SessionManager.php(482): Wikimedia\ObjectFactory\ObjectFactory->createObject()
  5. 4 /var/www/html/wiki/includes/session/SessionManager.php(541): MediaWiki\Session\SessionManager->getProviders()
  6. 5 /var/www/html/wiki/includes/session/SessionManager.php(248): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
  7. 6 /var/www/html/wiki/includes/Request/WebRequest.php(867): MediaWiki\Session\SessionManager->getSessionForRequest()
  8. 7 /var/www/html/wiki/includes/session/SessionManager.php(167): MediaWiki\Request\WebRequest->getSession()
  9. 8 /var/www/html/wiki/includes/Setup.php(492): MediaWiki\Session\SessionManager::getGlobalSession()
  10. 9 /var/www/html/wiki/includes/WebStart.php(85): require_once(string)
  11. 10 /var/www/html/wiki/index.php(50): require(string)
  12. 11 {main}
Could someone provide support or help? 138.97.21.202 20:33, 21 May 2025 (UTC) Reply
Edit the extension php file and add an if statement and you are fine. For my setup the path is:
> /var/www/html/wiki/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php
> just move the setting of hookContainer to the beginning of the constructor -> move up behind "{" $this->hookContainer = $hookContainer;
public function __construct(
Config $config,
HookContainer $hookContainer,
UserOptionsManager $userOptionsManager,
array $params = []
) {
$this->hookContainer = $hookContainer;
.... CODE
}
There is already a ticket and a fix for it but for whatever reason this fix is not included in the REL1_43 branch on git nor the dev-REL1_43 version from composer ( I assume they are the same but tested both anyway )
https://phabricator.wikimedia.org/T383786
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Auth_remoteuser/+/1111705/2/src/AuthRemoteuserSessionProvider.php
77.21.66.136 11:11, 23 June 2025 (UTC) Reply
Oh my missed deleting the old text. I just made a quck fix since I did not know about the Plugin Setup with but moving the one line is the constructor is just cleanerand also the official fix.
public function setUserNameReplaceFilter( array $replacepatterns ): void {
if (!isset($this->hookContainer)) {
// Fallback initialization using MediaWiki's service container
$this->hookContainer = \MediaWiki\MediaWikiServices::getInstance()->getHookContainer();
}
$this->hookContainer->register(
static::HOOKNAME,
static function ( &$username ) use ( $replacepatterns ) {
foreach ( $replacepatterns as $pattern => $replacement ) {
AtEase::suppressWarnings();
# If $pattern is no regex, create one from it.
// @phan-suppress-next-line PhanParamSuspiciousOrder
if ( preg_match( $pattern, '' ) === false ) {
$pattern = str_replace( '\\', '\\\\', $pattern );
$pattern = str_replace( '/', '\\/', $pattern );
$pattern = "/$pattern/";
}
AtEase::restoreWarnings();
$replaced = preg_replace( $pattern, $replacement, $username );
if ( $replaced === null ) {
return false;
}
$username = $replaced;
}
return true;
}a
);
} 77.21.66.136 11:14, 23 June 2025 (UTC) Reply
Thank you for the update! I've tried the suggested fix, but I think I've missed something. Downloaded the master tgz as referenced in the gerrit URL. But received the following error on the php run.php rebuildall.php.
    • Rebuilding links tables -- this can take a long time. It should be safe to abort via ctrl+C if you get bored.
Refreshing links from pages...
[610e5042f2a8278984f235f2] [no req] Error: Typed property MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider::$hookContainer must not be accessed before initialization
Backtrace:
from /var/www/html/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(247)
  1. 0 /var/www/html/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(203): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider->setUserNameReplaceFilter()
  2. 1 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory.php(240): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider->__construct()
  3. 2 /var/www/html/vendor/wikimedia/object-factory/src/ObjectFactory.php(149): Wikimedia\ObjectFactory\ObjectFactory::getObjectFromSpec()
  4. 3 /var/www/html/includes/session/SessionManager.php(482): Wikimedia\ObjectFactory\ObjectFactory->createObject()
  5. 4 /var/www/html/includes/session/SessionManager.php(541): MediaWiki\Session\SessionManager->getProviders()
  6. 5 /var/www/html/includes/session/SessionManager.php(248): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
  7. 6 /var/www/html/includes/Request/WebRequest.php(867): MediaWiki\Session\SessionManager->getSessionForRequest()
  8. 7 /var/www/html/includes/user/User.php(1079): MediaWiki\Request\WebRequest->getSession()
  9. 8 /var/www/html/includes/user/User.php(435): MediaWiki\User\User->loadFromSession()
  10. 9 /var/www/html/includes/user/User.php(1582): MediaWiki\User\User->load()
  11. 10 /var/www/html/includes/user/Options/UserOptionsManager.php(607): MediaWiki\User\User->getName()
  12. 11 /var/www/html/includes/user/Options/UserOptionsManager.php(262): MediaWiki\User\Options\UserOptionsManager->getCacheKey()
  13. 12 /var/www/html/extensions/Math/src/Hooks.php(107): MediaWiki\User\Options\UserOptionsManager->setOption()
  14. 13 /var/www/html/includes/HookContainer/HookContainer.php(159): MediaWiki\Extension\Math\Hooks->onMaintenanceRefreshLinksInit()
  15. 14 /var/www/html/includes/HookContainer/HookRunner.php(2510): MediaWiki\HookContainer\HookContainer->run()
  16. 15 /var/www/html/maintenance/refreshLinks.php(140): MediaWiki\HookContainer\HookRunner->onMaintenanceRefreshLinksInit()
  17. 16 /var/www/html/maintenance/refreshLinks.php(121): RefreshLinks->doRefreshLinks()
  18. 17 /var/www/html/maintenance/rebuildall.php(62): RefreshLinks->execute()
  19. 18 /var/www/html/maintenance/includes/MaintenanceRunner.php(703): RebuildAll->execute()
  20. 19 /var/www/html/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()
  21. 20 {main
I then commented the existing function setUserNameReplaceFilter and replaced it with the code example provided above. I'm not sure what I've missed as the following error is generated when users attempt to access the wiki.
[silenced-error] [1545f1821e88c55ca00cfc81] /index.php/Main_Page PHP Warning: preg_match(): No ending delimiter '@' found
  1. 0 [internal function]: MWExceptionHandler::handleError()
  2. 1 /var/www/html/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(283): preg_match()
  3. 2 /var/www/html/includes/HookContainer/HookContainer.php(159): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider::MediaWiki\Extension\Auth_remoteuser\{closure}()
  4. 3 /var/www/html/extensions/Auth_remoteuser/src/UserNameSessionProvider.php(307): MediaWiki\HookContainer\HookContainer->run()
  5. 4 /var/www/html/includes/session/SessionManager.php(542): MediaWiki\Extension\Auth_remoteuser\UserNameSessionProvider->provideSessionInfo()
  6. 5 /var/www/html/includes/session/SessionManager.php(248): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
  7. 6 /var/www/html/includes/Request/WebRequest.php(867): MediaWiki\Session\SessionManager->getSessionForRequest()
  8. 7 /var/www/html/includes/session/SessionManager.php(167): MediaWiki\Request\WebRequest->getSession()
  9. 8 /var/www/html/includes/Setup.php(492): MediaWiki\Session\SessionManager::getGlobalSession()
  10. 9 /var/www/html/includes/WebStart.php(85): require_once(string)
  11. 10 /var/www/html/index.php(50): require(string)
  12. 11 {main}
[silenced-error] [1545f1821e88c55ca00cfc81] /index.php/Main_Page PHP Warning: preg_match(): No ending delimiter '^' found
  1. 0 [internal function]: MWExceptionHandler::handleError()
  2. 1 /var/www/html/extensions/Auth_remoteuser/src/AuthRemoteuserSessionProvider.php(283): preg_match()
  3. 2 /var/www/html/includes/HookContainer/HookContainer.php(159): MediaWiki\Extension\Auth_remoteuser\AuthRemoteuserSessionProvider::MediaWiki\Extension\Auth_remoteuser\{closure}()
  4. 3 /var/www/html/extensions/Auth_remoteuser/src/UserNameSessionProvider.php(307): MediaWiki\HookContainer\HookContainer->run()
  5. 4 /var/www/html/includes/session/SessionManager.php(542): MediaWiki\Extension\Auth_remoteuser\UserNameSessionProvider->provideSessionInfo()
  6. 5 /var/www/html/includes/session/SessionManager.php(248): MediaWiki\Session\SessionManager->getSessionInfoForRequest()
  7. 6 /var/www/html/includes/Request/WebRequest.php(867): MediaWiki\Session\SessionManager->getSessionForRequest()
  8. 7 /var/www/html/includes/session/SessionManager.php(167): MediaWiki\Request\WebRequest->getSession()
  9. 8 /var/www/html/includes/Setup.php(492): MediaWiki\Session\SessionManager::getGlobalSession()
  10. 9 /var/www/html/includes/WebStart.php(85): require_once(string)
  11. 10 /var/www/html/index.php(50): require(string)
  12. 11 {main}
Thanks. 11L3290 (talk) 19:27, 30 June 2025 (UTC) Reply

Auto login not working due to domain name not resolved correctly

[edit ]
Latest comment: 1 year ago 2 comments1 person in discussion

Hi everyone,

We recently upgraded our MediaWiki instance from version 1.35 to 1.43, and since then, our LDAP autologon setup has stopped working. Previously, users were automatically logged in via LDAP without needing to manually enter credentials. Now, they’re redirected to the login page and must log in manually. Logging in manually via domain credentials still works.

Our Setup:
MediaWiki 1.43
LDAP Stack:
wfLoadExtension( 'PluggableAuth' );
wfLoadExtension( 'LDAPProvider' ); 
wfLoadExtension( 'LDAPAuthentication2' );
wfLoadExtension( 'LDAPAuthorization' );
wfLoadExtension( 'LDAPGroups' );
wfLoadExtension( 'LDAPUserInfo' );
wfLoadExtension( 'Auth_remoteuser' );
Configuration:
# PluggableAuth
$wgPluggableAuth_Config['Log In (do)'] = [
 'plugin' => 'LDAPAuthentication2',
 'data' => [ 'domain' => 'do.re.me-so.net' ]
];
$wgPluggableAuth_EnableAutoLogin = true;
$wgPluggableAuth_EnableLocalLogin = false;
# LDAP Provider
$LDAPProviderDomainConfigs = "$IP/provider/ldap.json";
$LDAPProviderDefaultDomain = "do.re.me-so.net";
# LDAPAuthentication2
$LDAPAuthentication2AllowLocalLogin = true;
$LDAPAuthentication2UsernameNormalizer = 'strtolower';
# LDAPAuthorization
$LDAPAuthorizationAutoAuthUsernameNormalizer = 'strtolower';
$LDAPAuthorizationAutoAuthRemoteUserStringParser = 'domain-backslash-username';
#AuthRemoteUser
$wgAuthRemoteuserUserNameReplaceFilter = [
	'^do\\' => 'do.re.me-so.net\\'
];
$wgAuthRemoteuserUserName = [
 $_SERVER[ 'REMOTE_USER' ]
];
But I can see in the logfiles:
mediawiki: MediaWiki\Extension\LDAPAuthorization\Hook\AuthRemoteuserFilterUserName: Check authorization for user 'DO\aUser'.
mediawiki: Resolved to username 'aUser' and domain 'DO'
mediawiki: Could not check login requirements for DO\aUser
mediawiki: No configuration available for domain 'do'!

If I shorten the domain from "do.re.me-so.net" to just "do" in my ldap.json I end up in a loop, but I can see in the logfiles that it successfully matches the user and domain, but does it endlessly.

Autologon worked perfectly in 1.35

All the extensions are updated to match our 1.43 LTS. Slk-fsk (talk) 06:08, 18 July 2025 (UTC) Reply

After reading through the related bug-reports ⚓ T383786 AuthRemoteuserFilterUserName hook not working in 1.43 where I had to make a change in order for the error not to appear, I'm starting to believe, that the whole filter function is not working at the moment.
The last discussion about this was in january. Is this still being worked on? Slk-fsk (talk) 08:31, 21 July 2025 (UTC) Reply

Trying 1.44 and Auth_remoteuser.

[edit ]
Latest comment: 10 months ago 3 comments2 people in discussion

Just an update. Tried using the latest build of Mediawiki (1.44) and updated all extensions, including Auth_remoteuser. There are still failures when using this extension. 11L3290 (talk) 15:35, 5 August 2025 (UTC) Reply

Also in my case, Auth_remoteuser does not work with Mediawiki 1.44 even if it is the only extension added to a vanilla Mediawiki installation. ~2025-46791-6 (talk) 11:48, 27 August 2025 (UTC) Reply
Just tried the patch released on 09/17/2025 by JRChamp as the master for RHE1_43. I believe this extension is now working correctly. Thank you!!!!!! https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/Auth_remoteuser/+/refs/heads/REL1_43 11L3290 (talk) 19:07, 22 September 2025 (UTC) Reply

User Accounts From Another CMS

[edit ]
Latest comment: 8 months ago 1 comment1 person in discussion

My website primarily uses another CMS (Flarum) and user accounts are created and managed inside that environment. I'd like to integrate MediaWiki into my website but I don't want it to have its own users. Instead I want it to use the user database inside Flarum and for any logging in/out throughout the website applies throughout the whole website. Is Auth remoteuser appropriate for my use case? ~2025-31929-76 (talk) 18:07, 7 November 2025 (UTC) Reply

AltStyle によって変換されたページ (->オリジナル) /