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

Increasing devise's default password length #5591

Open
angelamchoi opened this issue Apr 27, 2023 · 1 comment
Open

Increasing devise's default password length #5591

angelamchoi opened this issue Apr 27, 2023 · 1 comment

Comments

@angelamchoi
Copy link

angelamchoi commented Apr 27, 2023

Hi @carlosantoniodasilva and Devise team!

Currently, Devise's minimum password length is 6 characters long without any strict requirements on uppercase and lowercase, letters and symbols. For example, 123456, would be an acceptable password. I wanted to know if Devise would consider increasing the default password length to 10-12 min. characters long with stronger password requirements such as adding uppercase, lowercase, letters, and/or symbols to ensure all users have a secure password. I have attached an image for more information. I would love to work on this issue.

Please let me know if you have any questions.

Thank you.

image

@kykyi
Copy link

kykyi commented Aug 27, 2024

Great call @angelamchoi! @carlosantoniodasilva and Devise team can I open a PR adding some config which essentially does this?

# devise initializer
Devise.setup do |config|
      config.password_length = 8..128
      config.password_require_lower_case = true
      config.password_require_upper_case = true
      config.password_require_special_character = true
      config.password_require_number = true
end

# on devise model
 def password_complexity
    lower_case_regex = /(?=.*[a-z])/
    upper_case_regex = /(?=.*[A-Z])/
    digit_regex = /(?=.*[0-9])/
    special_char_regex = /(?=.*[\W])/

    [
      [lower_case_regex, :no_lowercase],
      [upper_case_regex, :no_uppercase],
      [digit_regex, :no_digit],
      [special_char_regex, :no_special]
    ].each do |regex, error|
      if !password.match?(regex)
        errors.add :password, error
      end
    end
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants