psecio / gatekeeper

Gatekeeper: An Authentication & Authorization Library
367 stars 23 forks source link

Allow for customization of password policy rules #14

Open enygma opened 9 years ago

enygma commented 9 years ago

Right now Gatekeeper does no password policy enforcement, it just uses the password as is. The ability should be added, maybe as a callback somehow, to define a set of rules on the value provided by the user.

Possible implementation:

<?php
Gatekeeper::setPasswordPolicy(function($password) {
    if (strlen($password) < 8) {
        throw new \Exception('Invalid password length!');
    }
});
?>

This would need to be appended to the UserModel somehow so it could be triggered on user create.