29 switch (strtolower(
$key)) {
30 case 'password_encoder':
34 case 'encoder_factory':
42 throw new \Exception(sprintf(
'"password_encoder" must be set in %s.', json_encode(
$config)));
46 throw new \ilUserException(sprintf(
'"encoder_factory" must be instance of \ilSetupPasswordEncoderFactory and set in %s.', json_encode(
$config)));
92 return $encoder->encodePassword($raw,
'');
104 public function verifyPassword(
string $encoded,
string $raw, callable $passwordReHashCallback) : bool
106 $currentEncoder = $this->
getEncoderFactory()->getFirstEncoderForEncodedPasswordAndMatchers(
109 'md5' =>
function ($encoded) {
110 return is_string($encoded) && strlen($encoded) === 32;
112 'bcryptphp' =>
function ($encoded) {
113 return is_string($encoded) && substr($encoded, 0, 4) ===
'$2y$' && strlen($encoded) === 60;
119 if ($currentEncoder->isPasswordValid($encoded, $raw,
'')) {
120 $passwordReHashCallback($raw);
123 } elseif ($currentEncoder->isPasswordValid($encoded, $raw,
'')) {
124 if ($currentEncoder->requiresReencoding($encoded)) {
125 $passwordReHashCallback($raw);
setEncoderName(string $encoderName)
__construct(array $config=[])
ilSetupPasswordManager constructor.
setEncoderFactory(\ilSetupPasswordEncoderFactory $encoderFactory)
encodePassword(string $raw)
Encodes the raw password based on the relevant encoding strategy.
Class ilSetupPasswordManager.
verifyPassword(string $encoded, string $raw, callable $passwordReHashCallback)
Verifies if the passed raw password matches the encoded one, based on the current encoding strategy...
Class ilSetupPasswordManager.