laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

[Proposal] Password Complexity Validation Rule. #1078

Open SketchNI opened 6 years ago

SketchNI commented 6 years ago

One thing I find myself writing over and over is the ability to accept/reject passwords based on their simplicity/complexity.

My proposal is a validation rule password with the following parameters:

Presets

Composites

I realise this will not be suited to a majority of use-cases but I'm hopeful that in time, this list can be expanded. This is all my currently sleep-deprived brain can think of.

Also note that either spelling of capitalized|capitalised will be accepted. I've already sacrificed my ability to spell colour correctly thanks to CSS. :stuck_out_tongue_winking_eye:

martinbean commented 6 years ago

@SketchNI Nice idea. I think this could be a cool use for a fluently-built validation rule. Something like:

'password' => [
    'required',
    'confirmed',
    Rule::password()
        ->minLength(8)
        ->numbers()
        ->lowercaseLetters()
        ->uppercaseLetters()
        ->specialCharacters(),
],

The numbers() / lowercaseLetters() / uppercaseLetters() / specialCharacters() methods could take a count parameter, specifying the number of each a password needs, i.e. specialCharacters(3).

SketchNI commented 6 years ago

I like your suggestion better. specialCharacters() could take an array of special char.. that's a dumb idea security-wise but the fluent method sounds much better than presets.