Skip to content

Conversation

mehrdadbozorgmehr
Copy link

@mehrdadbozorgmehr mehrdadbozorgmehr commented Aug 30, 2025

Closes gh-17706

@mehrdadbozorgmehr
Copy link
Author

Here is my PR. I’d really appreciate any feedback or suggestions for improvements.
Thanks for your time and guidance 🙏
@rwinch

@mehrdadbozorgmehr mehrdadbozorgmehr force-pushed the gh-17706 branch 2 times, most recently from ca45b53 to d9494ca Compare September 4, 2025 22:09
@mehrdadbozorgmehr mehrdadbozorgmehr changed the title Add Password4jPasswordEncoder for enhanced password hashing support Add password4j implementation of PasswordEncoder Sep 4, 2025
Copy link
Member

@rwinch rwinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR @mehrdadbozorgmehr!

I've provided feedback inline. Once those get addressed, we will want to discuss updating the documentation.

@mehrdadbozorgmehr mehrdadbozorgmehr force-pushed the gh-17706 branch 3 times, most recently from 099f552 to c4d71a5 Compare September 7, 2025 08:17
@mehrdadbozorgmehr mehrdadbozorgmehr force-pushed the gh-17706 branch 5 times, most recently from f3b431c to 04f994c Compare September 7, 2025 12:07
Copy link
Member

@rwinch rwinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress! Thanks again for your PR.

I've added a few inline comments. Please also add documentation to docs/modules/ROOT/pages/features/authentication/password-storage.adoc and docs/modules/ROOT/pages/features/whats-new.adoc

Copy link
Member

@rwinch rwinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we can reuse it as a base class for most of the algorithms, it looks like a single Password4jPasswordEncoder will not be possible. I've provided some feedback inline.

PS: Sorry for finding this late and reverting some of my previous feedback.

@mehrdadbozorgmehr
Copy link
Author

Thanks for pointing this out. I’ve updated the design by making Password4jPasswordEncoder abstract and introducing algorithm-specific subclasses for the working implementations. I’ve also implemented a PBKDF2-specific encoder and Balloon hashing in this PR with proper salt handling.

@rwinch , please let me know if any additional adjustments are required.

@rwinch rwinch added in: crypto An issue in spring-security-crypto type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 12, 2025
@rwinch rwinch self-assigned this Sep 12, 2025
Copy link
Member

@rwinch rwinch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes. Overall they look good. Please:

  • Rebase to resolve the conflict
  • Add documentation including a whats-new.adoc entry that links to the newly added documentation
  • Create two tickets:
    • For the password4j implementations supporting upgradeEncoding method
    • For the password4j implementations being able to match on the same algorithm when the algorithm contains different parameters. This can be done by using the static getInstanceFromHash(String) method on the implementation (e.g. BcryptFunction.getInstanceFromHash(String)). Note that not all implementations will be able to support this because not all hashes include the parameters in the resulting hash.

…hm selection and enhance documentation

Closes spring-projectsgh-17706

Signed-off-by: M.Bozorgmehr <[email protected]>

Add Password4jPasswordEncoder for enhanced password hashing support

Signed-off-by: M.Bozorgmehr <[email protected]>
Signed-off-by: M.Bozorgmehr <[email protected]>

Add Password4jPasswordEncoder for enhanced password hashing support

Signed-off-by: M.Bozorgmehr <[email protected]>
Signed-off-by: Mehrdad <[email protected]>
Signed-off-by: M.Bozorgmehr <[email protected]>
…hm selection and enhance documentation

Closes spring-projectsgh-17706

Signed-off-by: M.Bozorgmehr <[email protected]>
Signed-off-by: Mehrdad <[email protected]>
Signed-off-by: M.Bozorgmehr <[email protected]>
…rd encoders using Password4j library

Closes spring-projectsgh-17706

Signed-off-by: Mehrdad <[email protected]>
Signed-off-by: M.Bozorgmehr <[email protected]>
…BCrypt, Scrypt, PBKDF2, and Balloon hashing

Closes spring-projectsgh-17706

Signed-off-by: M.Bozorgmehr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: crypto An issue in spring-security-crypto type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add password4j implementation of PasswordEncoder
3 participants