|
|
|
@ -454,6 +454,28 @@ class IsekaiOIDCAuth extends AbstractPrimaryAuthenticationProvider {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function findOidcSubjectsByUserIds( array $userIds ) {
|
|
|
|
|
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancer()->getMaintenanceConnectionRef( DB_REPLICA );
|
|
|
|
|
$rows = $dbr->select(
|
|
|
|
|
[
|
|
|
|
|
self::OIDC_TABLE
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'oidc_user',
|
|
|
|
|
'oidc_subject'
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'oidc_user' => $userIds
|
|
|
|
|
],
|
|
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
$subjects = [];
|
|
|
|
|
foreach ( $rows as $row ) {
|
|
|
|
|
$subjects[$row->oidc_user] = $row->oidc_subject;
|
|
|
|
|
}
|
|
|
|
|
return $subjects;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static function getPreferredUsername( $config, $oidc, $realname, $email ) {
|
|
|
|
|
if ( isset( $config['preferred_username'] ) ) {
|
|
|
|
|
wfDebugLog( self::LOG_TAG, 'Using ' . $config['preferred_username'] .
|
|
|
|
@ -555,18 +577,19 @@ class IsekaiOIDCAuth extends AbstractPrimaryAuthenticationProvider {
|
|
|
|
|
$preferred_username = 'User';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( MediaWikiServices::getInstance()
|
|
|
|
|
->getUserIdentityLookup()
|
|
|
|
|
->getUserIdentityByName( $preferred_username ) ) {
|
|
|
|
|
$userIdentityLookup = MediaWikiServices::getInstance()->getUserIdentityLookup();
|
|
|
|
|
$userIdentity = $userIdentityLookup->getUserIdentityByName( $preferred_username );
|
|
|
|
|
if ( !$userIdentity || !$userIdentity->isRegistered() ) {
|
|
|
|
|
|
|
|
|
|
return $preferred_username;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$count = 1;
|
|
|
|
|
while ( MediaWikiServices::getInstance()
|
|
|
|
|
->getUserIdentityLookup()
|
|
|
|
|
->getUserIdentityByName( $preferred_username . $count ) ) {
|
|
|
|
|
|
|
|
|
|
while ( true ) {
|
|
|
|
|
$userIdentity = $userIdentityLookup->getUserIdentityByName( $preferred_username . $count );
|
|
|
|
|
if ( !$userIdentity || !$userIdentity->isRegistered() ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$count ++;
|
|
|
|
|
}
|
|
|
|
|
return $preferred_username . $count;
|
|
|
|
|