Passwords
Validates passwords against the policy that is configured via the auth.passwords option The policy can be defined as a set of preset rules, a regular expression or a custom callback.
Examples
// preset rules
'auth' => [
'passwords' => [
'minlength' => 12,
'uppercase' => true,
'lowercase' => true,
'digits' => 2,
'symbols' => true
]
];
// regular expression with a custom hint
'auth' => [
'passwords' => [
'rules' => '/^(?=.*\d)(?=.*[!@#$%^&*]).{16,}$/',
'hint' => 'At least 16 characters, one digit and one symbol'
]
];
// custom callback (return false or throw to reject)
'auth' => [
'passwords' => function (string $password): bool {
return str_contains($password, 'lizard');
}
];
// validate manually, e.g. in a frontend registration form
$kirby->auth()->passwords()->validate($password);