You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/features/authentication/password-storage.adoc
+215Lines changed: 215 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -463,6 +463,221 @@ There are a significant number of other `PasswordEncoder` implementations that e
463
463
They are all deprecated to indicate that they are no longer considered secure.
464
464
However, there are no plans to remove them, since it is difficult to migrate existing legacy systems.
465
465
466
+
[[authentication-password-storage-password4j]]
467
+
== Password4j-based Password Encoders
468
+
469
+
Spring Security 7.0 introduces alternative password encoder implementations based on the https://github.com/Password4j/password4j[Password4j] library. These encoders provide additional options for popular hashing algorithms and can be used as alternatives to the existing Spring Security implementations.
470
+
471
+
The Password4j library is a Java cryptographic library that focuses on password hashing with support for multiple algorithms. These encoders are particularly useful when you need specific algorithm configurations or want to leverage Password4j's optimizations.
472
+
473
+
All Password4j-based encoders are thread-safe and can be shared across multiple threads.
The `Argon2Password4jPasswordEncoder` implementation uses the https://en.wikipedia.org/wiki/Argon2[Argon2] algorithm via the Password4j library to hash passwords.
479
+
This provides an alternative to Spring Security's built-in `Argon2PasswordEncoder` with different configuration options and potential performance characteristics.
480
+
481
+
Argon2 is the winner of the https://en.wikipedia.org/wiki/Password_Hashing_Competition[Password Hashing Competition] and is recommended for new applications.
482
+
This implementation leverages Password4j's Argon2 support which properly includes the salt in the output hash.
483
+
484
+
.Argon2Password4jPasswordEncoder
485
+
[tabs]
486
+
======
487
+
Java::
488
+
+
489
+
[source,java,role="primary"]
490
+
----
491
+
// Create an encoder with default settings
492
+
Argon2Password4jPasswordEncoder encoder = new Argon2Password4jPasswordEncoder();
The `BcryptPassword4jPasswordEncoder` implementation uses the https://en.wikipedia.org/wiki/Bcrypt[BCrypt] algorithm via the Password4j library to hash passwords.
520
+
This provides an alternative to Spring Security's built-in `BCryptPasswordEncoder` with Password4j's implementation characteristics.
521
+
522
+
BCrypt is a well-established password hashing algorithm that includes built-in salt generation and is resistant to rainbow table attacks.
523
+
This implementation leverages Password4j's BCrypt support which properly includes the salt in the output hash.
524
+
525
+
.BcryptPassword4jPasswordEncoder
526
+
[tabs]
527
+
======
528
+
Java::
529
+
+
530
+
[source,java,role="primary"]
531
+
----
532
+
// Create an encoder with default settings
533
+
BcryptPassword4jPasswordEncoder encoder = new BcryptPassword4jPasswordEncoder();
The `ScryptPassword4jPasswordEncoder` implementation uses the https://en.wikipedia.org/wiki/Scrypt[SCrypt] algorithm via the Password4j library to hash passwords.
561
+
This provides an alternative to Spring Security's built-in `SCryptPasswordEncoder` with Password4j's implementation characteristics.
562
+
563
+
SCrypt is a memory-hard password hashing algorithm designed to be resistant to hardware brute-force attacks.
564
+
This implementation leverages Password4j's SCrypt support which properly includes the salt in the output hash.
565
+
566
+
.ScryptPassword4jPasswordEncoder
567
+
[tabs]
568
+
======
569
+
Java::
570
+
+
571
+
[source,java,role="primary"]
572
+
----
573
+
// Create an encoder with default settings
574
+
ScryptPassword4jPasswordEncoder encoder = new ScryptPassword4jPasswordEncoder();
The `Pbkdf2Password4jPasswordEncoder` implementation uses the https://en.wikipedia.org/wiki/PBKDF2[PBKDF2] algorithm via the Password4j library to hash passwords.
602
+
This provides an alternative to Spring Security's built-in `Pbkdf2PasswordEncoder` with explicit salt management.
603
+
604
+
PBKDF2 is a key derivation function designed to be computationally expensive to thwart dictionary and brute force attacks.
605
+
This implementation handles salt management explicitly since Password4j's PBKDF2 implementation does not include the salt in the output hash.
606
+
The encoded password format is: `{salt}:{hash}` where both salt and hash are Base64 encoded.
607
+
608
+
.Pbkdf2Password4jPasswordEncoder
609
+
[tabs]
610
+
======
611
+
Java::
612
+
+
613
+
[source,java,role="primary"]
614
+
----
615
+
// Create an encoder with default settings
616
+
Pbkdf2Password4jPasswordEncoder encoder = new Pbkdf2Password4jPasswordEncoder();
0 commit comments