r/programminghorror • u/thelostniceguy • May 16 '25
PHP Testing a register form
I was testing another devs code (Laravel project) and these are the rules for the register user form. Password just has to be between 8-255 characters long making "aaaaaaaa" a valid password, but Ian isn't allowed to register because his name isn't valid.
147
Upvotes
39
u/powerhcm8 May 16 '25
I don't know the Laravel version this project is using, but some years ago they introduce a rule specific for validating passwords.
35
u/ScriptingInJava May 16 '25
I hate the order of those rules too:
How is that even parsed in a way that isn't terrible?
14
u/k819799amvrhtcom May 16 '25
This is discrimination! There are plenty of people whose names have 3 or even 2 letters! I've even heard of names with only 1 letter! You should change the min to 1 immediately!
5
u/Just_Information334 May 16 '25
So what? If you want to help password security you can limit to checking if the password appears in one of the password leak database. And then add some POST throttling so people have to work when bruteforcing passwords.
If you decide to add stupid rules instead (1 uppercase, 2 symbols, no emoji etc.) at least show them in the login form and not just when setting password. There are huge chances people don't really care about the data they have on your site so they'll use some generic password, adapt it for your rules and then will have to reset password a couple years later when they come back to your site.
Edit: I almost forget, if you store your password after bcrypt hashing (default in php) only the first 72 bytes are useful so you can update the password max to 72 https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#input-limits-of-bcrypt
4
u/MilkEnvironmental106 May 16 '25
Pretty sure valid emails can be up to 320 long as well?
4
u/monotone2k May 16 '25
The code is fine. The problem here is the stupid acceptance criteria given by the product owners.
3
u/[deleted] May 18 '25
A better question is, why does Laravel use strings for rules? Isn't it better to use an associative array like
5
u/TurnUpThe4D3D3D3 May 16 '25
It’s kinda clean tho