Password encoding upgrade is insufficiently configurable #8973
Labels
in: crypto
An issue in spring-security-crypto
status: declined
A suggestion or change that we don't feel we should currently apply
Uh oh!
There was an error while loading. Please reload this page.
Summary
Hello,
I ran into #8498 this week. Specifically:
So I would like to request that the password upgrade feature be made more configurable.
Actual Behavior
Upon encountering a BCrypt password hash of any strength smaller than 10, Spring Security will internally re-encode the plaintext matching this hash (once it is presented by a client) with a BCrypt encoder with strength 10. From that point on, all plaintext to hash comparisons will be performed at strength 10. This imposes a significant performance cost if done often.
This happens because:
org.springframework.security.crypto.factory.PasswordEncoderFactories#createDelegatingPasswordEncoder()
creates aBCryptPasswordEncoder
with strength 10 (not configurable).org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder#upgradeEncoding
returns true if the strength of the encoded password is smaller than the strength of that encoder instance, i.e. 10 (also not configurable).I worked around this issue by defining my own
DelegatingPasswordEncoder
with its own custom-strengthBCryptPasswordEncoder
. That seems like a bit too much work for someone just wanting to use HTTP Basic Auth.Expected Behavior
One or more of the following:
Configuration
See the attached project.
Version
Spring Security 5.3.4.RELEASE.
Sample
Attached.
demo.zip
Thank you.
The text was updated successfully, but these errors were encountered: