Does having a space at the end constitute a valid password
e.g "ABCD " or "ABCD12 "
Would it be fine, if we trim the password input (i.e "ABCD" would be the effective string after trimming) prior to authentication
Does having a space at the end constitute a valid password
e.g "ABCD " or "ABCD12 "
Would it be fine, if we trim the password input (i.e "ABCD" would be the effective string after trimming) prior to authentication
Technically yes - a password can contain anything you want it to. However, what's actually allowed will depend on a number of factors including hashing algorithm, how the data is stored etc.
If you are going to trim the password then you need to state "no trailing spaces" when the user enters the data.
I tend to trim "silently" almost everything the user types, as spaces are generally not shown in form elements.
But, for password fields, there is a '*' or an equivalent -- so even spaces are "visible" ; so you can't trim the input silently.
Still, I would consider a password with a space at the beginning or end is not valid, and ask the user to modify it -- but that's probably a matter of personnal taste.
(Considering a user typing a space at the beginning or end of a password field is quite a rare situation, I would not indicate anything saying this is not allowed, though -- until the user actually does that, of course : a registration form is already quite too complex for most users, so no need to say that kind of little/rare thing until it happens)
I wouldn't consider a space a valid password character. It's not something that is usually done. So it would be fine to trim before authentication.
I'd say it's probably a bad idea to use a password like that, but it's an even worse idea to arbitarily change what they entered for a password.
If you're password creation procedure disallowed password which end in a space, than it should be OK.
A space at the end of a password is perfectly valid, and indeed would help protect it if printed. Why restrict users from what password they choose, it can't add value.
I agree with those who say that while it could be regarded as a valid character, I wouldn't recommend it, since it will add to possible confusion and not really add any value.
Using a space in a password is something that I can only guess is rarely done and uncommon to standard user behaviour. Therefore I think it would be fine if you explicitly exclude spaces from passwords and alerting the user when he chooses a password which holds a space. I wouldn't trim the password without giving the user feedback in case that they chose a space on purpose and are confused when they can't log in afterwards.
To be fair, this is just gut feeling about how passwords should work. I can't think of a reason why it should absolutely be forbidden to use spaces in a password.