Do not strip leading or trailing whitespaces in password fields #605
+4
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default behavior of the CharField class in Django forms is to strip leading and trailing whitespaces from the input text - see https://docs.djangoproject.com/en/4.2/ref/forms/fields/#django.forms.CharField.strip.
For authentication, this means that a user with a password containing leading or trailing whitespace is currently unable to log in via OMERO.web.
This commit fixes the login form as well as the change password form to preserve leading/trailing whitespace in all passwords fields.
Two workflows should be tested for this change
authentication workflow
a. create a new user
b. change its password using the OMERO CLI (
omero user password
) and set a value including a leading or trailing passwordc. log in via OMERO CLI using the new password should work and confirm the password has been set in the DB
d. log in via OMERO.web using the new password should fail without this PR but succeed with this PR
password change workflow
a. create a new user
b. change its password using the OMERO Web (my account or as an admin) and set a value including a leading or trailing password
c. log in via OMERO CLI using the new password should fail without this PR and succeed with this PR
d. log in via OMERO.web using the new password should succeed without this PR (as the whitespaces will be stripped from both forms) as well as with this PR
/cc @stick