-
Notifications
You must be signed in to change notification settings - Fork 6k
Add DelegatingPasswordEncoder #4666
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
Comments
Most security systems aims at even administrator should not be able to make out what passwords are. I think storing plain {pbkdf2} or {bcrypt} or any such keys along with passwords just to make out what encryption strategy is used may pose a security threat. It would be great if the encryption of such keys stored along with passwords is also encrypted via a configurable strategy in the application. So that people might configure which encryption strategy is to be used to encrypt encryption keys. I store password started in amazon S3 bucket, which is connected at time of application boot. This is one way of implementing the password startegy which even my db administrator is not even aware of. You might think of many such usecases. In the nutshell, even plain passwords to db administrator should be hard to decrypt. |
These are not keys. They are identifiers which is a lot different. Key's must be kept secret, but ids do not need to be.
First we are not encrypting the passwords. I think this might be where the disconnect is. This mechanism is only for validating a user's password. It is not used for storing a password that must be used presented later on (i.e. for connecting to a database). The storage mechanisms for these two use cases are quite different. You do not encrypt passwords for users. You hash them using a one way hash. Second, it only takes basic knowledge of hashing algorithms to discover which hashing algorithm was used. For example, if passwords start with Finally, the fundamental principals of cryptography state that it should work even if the adversary knows the algorithm you are using. So, giving this information away, should not be a security thread. Can you provide any evidence that this is a security thread? This mechanism was the recommendation of password experts as discussed on #2774 so I'd be very interested if you have some additional insights. I will add that you can use whatever identifier you want to map it to another |
@rwinch Rob, with time, the data of rainbow table has grown too large and surprisingly even a salted hash can also be broken. To quote, I was surprised my password hash whose password was 10 character long with special symbol, small and uppercase and also with digits, was broken by rainbow table attack in few minutes. Apart from that I am not sure about security experts, but in our security company its not allowed to expose what algo we are using for cryptography. Only us and our S3 bucket knows what it is. Our legacy systems after user creates a password, keeps on changing the hashes after every login by changing salts. User is bound to change his password after certain logins, to ensure his credentials privacy. The password algo and key strength is changed after every deployment and the passwords are migrated once user logs in with updated timestamp. I like the idea of keeping the algo as part of key, anyway we also need to keep a track of it in application with datetime of deployment, to migrate user passwords. All I was saying if that algo name could be encrypted becomes beneficial for secured critical systems. |
Summary
Create a DelegatingPasswordEncoder which supports delegating to multiple different PasswordEncoder implementations.
The following values would be stored:
We would then use the following logic for matching:
PasswordEncoder
id ofbcrypt
andencodedPassword of
$2a$10$dXJ3SW6G7P50lGmMkkmwe.20cQQubK3.HZWzG3YB1tlRy.fqvM/BG
.When matching it would delegate to
BCryptPasswordEncoder
PasswordEncoder
id ofnoop
andencodedPassword of
password
. When matching it would delegate toNoOpPasswordEncoder
PasswordEncoder
id ofpbkdf2
andencodedPassword of
5d923b44a6d129f3ddf3e3c8d29412723dcbde72445e8ef6bf3b508fbf17fa4ed4d6b99ca763d8dc
.When matching it would delegate to
Pbkdf2PasswordEncoder
PasswordEncoder
id ofscrypt
andencodedPassword of
$e0801$8bWJaSu2IKSn9Z9kM+TPXfOc/9bdYSrN1oD9qfVThWEwdRTnO7re7Ei+fUZRJ68k9lTyuTeUp4of4g24hHnazw==$OAOec05+bXxvuu/1qZ6NUR+xQYvYv7BeL1QxwRpY5Pc=
When matching it would delegate to
SCryptPasswordEncoder
PasswordEncoder
id ofsha256
andencodedPassword of
97cde38028ad898ebc02e690819fa220e88c62e0699403e94fff291cfffaf8410849f27605abcbc0
.When matching it would delegate to
StandardPasswordEncoder
The text was updated successfully, but these errors were encountered: