auth: Replace FQNs with imports

Change-Id: If77151460187f304beb7e842b0347f4ba715987e
This commit is contained in:
Lucas Werkmeister 2022-12-16 11:25:32 +01:00
parent 523ab7cff8
commit bac2f3f64d
4 changed files with 18 additions and 10 deletions

View file

@ -23,7 +23,9 @@
namespace MediaWiki\Auth;
use MediaWiki\Language\RawMessage;
use Message;
use UnexpectedValueException;
/**
* This is a value object for authentication requests.
@ -235,8 +237,8 @@ abstract class AuthenticationRequest {
*/
public function describeCredentials() {
return [
'provider' => new \MediaWiki\Language\RawMessage( '$1', [ get_called_class() ] ),
'account' => new \MediaWiki\Language\RawMessage( '$1', [ $this->getUniqueId() ] ),
'provider' => new RawMessage( '$1', [ get_called_class() ] ),
'account' => new RawMessage( '$1', [ $this->getUniqueId() ] ),
];
}
@ -289,7 +291,7 @@ abstract class AuthenticationRequest {
*
* @param AuthenticationRequest[] $reqs
* @return string|null
* @throws \UnexpectedValueException If multiple different usernames are present.
* @throws UnexpectedValueException If multiple different usernames are present.
*/
public static function getUsernameFromRequests( array $reqs ) {
$username = null;
@ -302,7 +304,7 @@ abstract class AuthenticationRequest {
$otherClass = get_class( $req );
} elseif ( $username !== $req->username ) {
$requestClass = get_class( $req );
throw new \UnexpectedValueException( "Conflicting username fields: \"{$req->username}\" from "
throw new UnexpectedValueException( "Conflicting username fields: \"{$req->username}\" from "
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression $otherClass always set
. "$requestClass::\$username vs. \"$username\" from $otherClass::\$username" );
}
@ -315,7 +317,7 @@ abstract class AuthenticationRequest {
* Merge the output of multiple AuthenticationRequest::getFieldInfo() calls.
* @param AuthenticationRequest[] $reqs
* @return array
* @throws \UnexpectedValueException If fields cannot be merged
* @throws UnexpectedValueException If fields cannot be merged
*/
public static function mergeFieldInfo( array $reqs ) {
$merged = [];
@ -366,7 +368,7 @@ abstract class AuthenticationRequest {
if ( !array_key_exists( $name, $merged ) ) {
$merged[$name] = $options;
} elseif ( $merged[$name]['type'] !== $type ) {
throw new \UnexpectedValueException( "Field type conflict for \"$name\", " .
throw new UnexpectedValueException( "Field type conflict for \"$name\", " .
"\"{$merged[$name]['type']}\" vs \"$type\""
);
} else {

View file

@ -21,6 +21,8 @@
namespace MediaWiki\Auth;
use MediaWiki\Language\RawMessage;
/**
* This is a value object for authentication requests with a username and password
* @stable to extend
@ -88,7 +90,7 @@ class PasswordAuthenticationRequest extends AuthenticationRequest {
public function describeCredentials() {
return [
'provider' => wfMessage( 'authmanager-provider-password' ),
'account' => new \MediaWiki\Language\RawMessage( '$1', [ $this->username ] ),
'account' => new RawMessage( '$1', [ $this->username ] ),
];
}
}

View file

@ -21,6 +21,8 @@
namespace MediaWiki\Auth;
use MediaWiki\Language\RawMessage;
/**
* This is a value object for authentication requests with a username, password, and domain
* @stable to extend
@ -58,7 +60,7 @@ class PasswordDomainAuthenticationRequest extends PasswordAuthenticationRequest
'help' => wfMessage( 'authmanager-domain-help' ),
];
foreach ( $this->domainList as $domain ) {
$ret['domain']['options'][$domain] = new \MediaWiki\Language\RawMessage( '$1', [ $domain ] );
$ret['domain']['options'][$domain] = new RawMessage( '$1', [ $domain ] );
}
}

View file

@ -21,8 +21,10 @@
namespace MediaWiki\Auth;
use MediaWiki\Language\RawMessage;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use PasswordFactory;
/**
* This represents the intention to set a temporary password for the user.
@ -81,7 +83,7 @@ class TemporaryPasswordAuthenticationRequest extends AuthenticationRequest {
}
}
$password = \PasswordFactory::generateRandomPasswordString( $minLength );
$password = PasswordFactory::generateRandomPasswordString( $minLength );
return new self( $password );
}
@ -102,7 +104,7 @@ class TemporaryPasswordAuthenticationRequest extends AuthenticationRequest {
public function describeCredentials() {
return [
'provider' => wfMessage( 'authmanager-provider-temporarypassword' ),
'account' => new \MediaWiki\Language\RawMessage( '$1', [ $this->username ] ),
'account' => new RawMessage( '$1', [ $this->username ] ),
] + parent::describeCredentials();
}