|
MediaWiki master
|
Factory class for creating and checking Password objects. More...
Public Member Functions | |
| __construct (array $config=[], string $default='') | |
| Most of the time you'll want to use MediaWikiServices::getInstance()->getPasswordFactory instead. | |
| getDefaultType () | |
| Get the default password type. | |
| getTypes () | |
| Get the list of types of passwords. | |
| needsUpdate (Password $password) | |
| Determine whether a password object needs updating. | |
| newFromCiphertext (?string $hash) | |
| Create a new Password object from an existing string hash. | |
| newFromPlaintext (?string $password, ?Password $existing=null) | |
| Create a new Password object from a plaintext password. | |
| newFromType (string $type) | |
| Create a new Password object of the given type. | |
| register (string $type, array $config) | |
| Register a new type of password hash. | |
| setDefaultType (string $type) | |
| Set the default password type. | |
Static Public Member Functions | |
| static | generateRandomPasswordString (int $minLength=10) |
| Generate a random string suitable for a password. | |
| static | newInvalidPassword () |
| Create an InvalidPassword. | |
Factory class for creating and checking Password objects.
Definition at line 22 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::__construct | ( | array | $config = [], |
| string | $default = '' ) |
Most of the time you'll want to use MediaWikiServices::getInstance()->getPasswordFactory instead.
| array | $config | Mapping of password type => config |
| string | $default | Default password type |
Definition at line 52 of file PasswordFactory.php.
References MediaWiki\Password\PasswordFactory\setDefaultType().
|
static |
Generate a random string suitable for a password.
| int | $minLength | Minimum length of password to generate |
Definition at line 211 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::getDefaultType | ( | ) |
Get the default password type.
Definition at line 94 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::getTypes | ( | ) |
Get the list of types of passwords.
Definition at line 103 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::needsUpdate | ( | Password | $password | ) |
Determine whether a password object needs updating.
Check whether the given password is of the default type. If it is, pass off further needsUpdate checks to Password::needsUpdate.
| Password | $password |
Definition at line 197 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::newFromCiphertext | ( | ?string | $hash | ) |
Create a new Password object from an existing string hash.
Parse the type of a hash and create a new hash object based on the parsed type. Pass the raw hash to the constructor of the new object. Use InvalidPassword type if a null hash is given.
| string | null | $hash | Existing hash or null for an invalid password |
| PasswordError | If hash is invalid or type is not recognized |
Definition at line 118 of file PasswordFactory.php.
Referenced by MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProvider\getPassword().
| MediaWiki\Password\PasswordFactory::newFromPlaintext | ( | ?string | $password, |
| ?Password | $existing = null ) |
Create a new Password object from a plaintext password.
If no existing object is given, make a new default object. If one is given, clone that object. Then pass the plaintext to Password::crypt().
| string | null | $password | Plaintext password, or null for an invalid password |
| Password | null | $existing | Optional existing hash to get options from |
Definition at line 171 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::newFromType | ( | string | $type | ) |
Create a new Password object of the given type.
| string | $type | Existing type |
| PasswordError | If type is not recognized |
Definition at line 136 of file PasswordFactory.php.
|
static |
Create an InvalidPassword.
Definition at line 224 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::register | ( | string | $type, |
| array | $config ) |
Register a new type of password hash.
| string | $type | Unique type name for the hash. Will be prefixed to the password hashes to identify what hashing method was used. |
| array | $config | Array of configuration options. 'class' is required (the Password subclass name), everything else is passed to the constructor of that class. |
Definition at line 70 of file PasswordFactory.php.
| MediaWiki\Password\PasswordFactory::setDefaultType | ( | string | $type | ) |
Set the default password type.
This type will be used for creating new passwords when the type is not specified. Passwords of a different type will be considered outdated and in need of update.
| string | $type | Password hash type |
| InvalidArgumentException | If the type is not registered |
Definition at line 84 of file PasswordFactory.php.
Referenced by MediaWiki\Password\PasswordFactory\__construct().