Skip to content

Restore ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED - #59627

Open
thomasklemm wants to merge 1 commit into
rails:mainfrom
thomasklemm:thomasklemm/restore-max-password-length
Open

thomasklemm wants to merge 1 commit into
rails:mainfrom
thomasklemm:thomasklemm/restore-max-password-length

Conversation

@thomasklemm

@thomasklemm thomasklemm commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

This keeps ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED as a public constant that points at BCryptPassword::MAX_PASSWORD_LENGTH_ALLOWED. #56041 moved the constant into the new BCryptPassword class when it added algorithm:. The removal is unreleased.

Applications and gems use the old name to cap password length, so on main they raise NameError when the code loads:

# Spree 6.0.2, spree/core/lib/spree/core/configuration.rb
preference :maximum_password_length, :integer, default: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED, env: 'SPREE_MAXIMUM_PASSWORD_LENGTH'

# open-build-service, src/api/app/models/user.rb
validates :password, length: { minimum: 6, maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED }, allow_nil: true

Sources: Spree 6.0.2, open-build-service master.

The constant preserves the BCrypt byte limit and is defined directly on SecurePassword again, as in 8.1. Loading stays as lazy as on main: SecurePassword already requires bcrypt_password.rb, and the bcrypt gem is still only required when a password is hashed. The new test fails without the constant.


Found by comparing the public API of 8-1-stable and main and searching released gems and apps for callers of what was removed (record, part of my research project Lowrail).

rails#56041 moved the constant to the new BCryptPassword class. Applications
and gems use it to cap password length, for example Spree's
maximum_password_length preference and open-build-service's User
validation, and raise NameError on main when that code loads.

Keep the public constant on SecurePassword, pointing at the BCrypt limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant