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
+83-1Lines changed: 83 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ An adaptive one-way function allows configuring a "`work factor`" that can grow
39
39
We recommend that the "`work factor`" be tuned to take about one second to verify a password on your system.
40
40
This trade off is to make it difficult for attackers to crack the password, but not so costly that it puts excessive burden on your own system or irritates users.
41
41
Spring Security has attempted to provide a good starting point for the "`work factor`", but we encourage users to customize the "`work factor`" for their own system, since the performance varies drastically from system to system.
42
-
Examples of adaptive one-way functions that should be used include <<authentication-password-storage-bcrypt,bcrypt>>, <<authentication-password-storage-pbkdf2,PBKDF2>>, <<authentication-password-storage-scrypt,scrypt>>, and <<authentication-password-storage-argon2,argon2>>.
42
+
Examples of adaptive one-way functions that should be used include <<authentication-password-storage-bcrypt,bcrypt>>, <<authentication-password-storage-pbkdf2,PBKDF2>>, <<authentication-password-storage-scrypt,scrypt>>, <<authentication-password-storage-argon2,argon2>>, and <<authentication-password-storage-password4j,password4j>>.
43
43
44
44
Because adaptive one-way functions are intentionally resource intensive, validating a username and password for every request can significantly degrade the performance of an application.
45
45
There is nothing Spring Security (or any other library) can do to speed up the validation of the password, since security is gained by making the validation resource intensive.
The `Password4jPasswordEncoder` implementation uses the https://github.com/Password4j/password4j[Password4j] library to hash passwords.
463
+
Password4j provides a unified interface for multiple password hashing algorithms including BCrypt, SCrypt, Argon2, and PBKDF2.
464
+
This encoder allows you to leverage the Password4j library's optimized implementations and automatic algorithm detection capabilities.
465
+
466
+
Like other adaptive one-way functions, the underlying algorithms should be tuned to take about 1 second to verify a password on your system.
467
+
Password4j provides secure default configurations through its `AlgorithmFinder` class, making it easy to get started with properly configured password encoders.
468
+
469
+
.Password4jPasswordEncoder with BCrypt
470
+
[tabs]
471
+
======
472
+
Java::
473
+
+
474
+
[source,java,role="primary"]
475
+
----
476
+
// Using Password4j's default BCrypt configuration (recommended)
477
+
PasswordEncoder encoder = new Password4jPasswordEncoder(AlgorithmFinder.getBcryptInstance());
Password4j also supports SCrypt and PBKDF2 algorithms through similar patterns using `AlgorithmFinder.getScryptInstance()` and `AlgorithmFinder.getPBKDF2Instance()` respectively.
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/whats-new.adoc
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,10 @@ Each section that follows will indicate the more notable removals as well as the
13
13
14
14
* Removed `AuthorizationManager#check` in favor of `AuthorizationManager#authorize`
15
15
16
+
== Crypto
17
+
18
+
* Added `Password4jPasswordEncoder` that integrates with the https://github.com/Password4j/password4j[Password4j] library, providing support for multiple password hashing algorithms including BCrypt, SCrypt, Argon2, and PBKDF2 through a unified interface
19
+
16
20
== Config
17
21
18
22
* Support modular configuration in xref::servlet/configuration/java.adoc#modular-httpsecurity-configuration[Servlets] and xref::reactive/configuration/webflux.adoc#modular-serverhttpsecurity-configuration[WebFlux]
0 commit comments