Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YesorNo Field option for a special char in random password generation, also make sure that special char always present if intended #3333

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

FuzzyParrabellum
Copy link
Contributor

cf issue #3327 - Setting a password policy that requires "special" symbols breaks the random password generator

Before PR, if user wanted to have a special character in their randomly generated password upon user creation, they had to directely change AUTH_PASSWORD_VALIDATORS in settings.py. That behavior could lead to an infinite while loop bug with custom make_password() function in modoboa\modoboa\admin\lib.py.

After PR :

  • User directly has option (with yes/no radiobutton) in its account parameters to allow for special characters in new randomly generated user passwords.
  • Now random password generator function make_password() always include at least one of the possible string groups ascii_letters, digits (and punctuation/special characters, if user chose so in its account parameters).
  • Set a max of 10 tries of make_password() call.

certain_chars = ''
for i in range(10): # limit tries
if allow_special_characters: # add special characters in random passwd
possible_chars_types.append(string.punctuation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't you adding it at each try ?

@@ -346,6 +346,10 @@ def test_random_password(self):
"email": "tester@test.com",
"stepid": "step2",
}
# TODO: add test to check if unhashed password created with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you got time to do it ?

rdzantoine.pro@gmail.com and others added 6 commits December 21, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants