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

Support dynamic password lengths for Rails > 5.2 #5166

Closed
wants to merge 2 commits into from

Conversation

manojmj92
Copy link
Contributor

@manojmj92 manojmj92 commented Nov 26, 2019

Hello,

Rails now supports length validator to have dynamic min and max values.

I feel this would be a nice addition to have Devise support this feature. I have made the change such that no current installations of Devise will have trouble with this change. Everything should work as perfectly as before.

This change is useful for instances where applications have the need to support dynamic password lengths, without a system restart. Such applications will just have to override the password_length method in their own classes to support dynamic password lengths.

Real world use case: We have been trying to implement dynamic password length at GitLab. Implementation issue: https://gitlab.com/gitlab-org/gitlab/issues/36776
Right now, we have implemented the same using a monkey patch for the password length validator

@sourcelevel-bot
Copy link

Hello, @manojmj92! This is your first Pull Request that will be reviewed by SourceLevel, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

lib/devise.rb Outdated Show resolved Hide resolved
@manojmj92 manojmj92 force-pushed the dynamic_password_length branch from 032f163 to ca66541 Compare November 26, 2019 18:57
@sourcelevel-bot
Copy link

SourceLevel has finished reviewing this Pull Request and has found:

  • 2 possible new issues (including those that may have been commented here).

See more details about this review.

@manojmj92 manojmj92 force-pushed the dynamic_password_length branch 2 times, most recently from dcfc2c3 to 3fd43fc Compare November 27, 2019 05:28
@manojmj92
Copy link
Contributor Author

Hello @tegon, could you kindly review? 🙂

@manojmj92
Copy link
Contributor Author

@carlosantoniodasilva could you please review? 🙂

@carlosantoniodasilva
Copy link
Member

@manojmj92 sorry about the delay here, things have been a bit crazy but this is on my radar to get back to you. Thanks for the work.

@manojmj92 manojmj92 force-pushed the dynamic_password_length branch from 3fd43fc to 188fe6c Compare May 11, 2020 16:23
@manojmj92
Copy link
Contributor Author

Hello @carlosantoniodasilva, could you please review? 🙂

@carlosantoniodasilva
Copy link
Member

@manojmj92 yes, my apologies, this one slipped through the cracks, appreciate the ping. I've recently started to catch up on some of the issues/PRs here and this one is high on my radar, I'll get to it soon, just have a few other things to wrap up first.

@ghiculescu
Copy link
Contributor

Such applications will just have to override the password_length method in their own classes to support dynamic password lengths.

It would be helpful to see an example, maybe in the CHANGELOG. I found https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/user.rb#L488 which gave me a better idea of what's being proposed.

@nashby
Copy link
Collaborator

nashby commented Nov 29, 2024

@manojmj92 thanks for PR! I updated it (since we dropped Rails 5.2 support) here #5734 and merged.

@nashby nashby closed this Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants