Refine upgradeEncoding condition in DaoAuthenticationProvider
After adding jspecify support in the module that contains the DaoAuthenticationProvider class, we actually changed the contract logic, which is a good thing, and this commit fixes it. Closes: gh-18781 Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
This commit is contained in:
committed by
Josh Cummings
parent
fdaa883fb7
commit
4f97217f68
+4
-1
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.security.authentication.dao;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
@@ -43,6 +44,7 @@ import org.springframework.util.function.SingletonSupplier;
|
||||
*
|
||||
* @author Ben Alex
|
||||
* @author Rob Winch
|
||||
* @author Andrey Litvitski
|
||||
*/
|
||||
public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
|
||||
|
||||
@@ -131,7 +133,8 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
||||
throw new CompromisedPasswordException("The provided password is compromised, please change your password");
|
||||
}
|
||||
String existingEncodedPassword = user.getPassword();
|
||||
boolean upgradeEncoding = existingEncodedPassword != null && this.userDetailsPasswordService != null
|
||||
boolean upgradeEncoding = existingEncodedPassword != null
|
||||
&& !Objects.equals(this.userDetailsPasswordService, UserDetailsPasswordService.NOOP)
|
||||
&& this.passwordEncoder.get().upgradeEncoding(existingEncodedPassword);
|
||||
if (upgradeEncoding) {
|
||||
String newPassword = this.passwordEncoder.get().encode(presentedPassword);
|
||||
|
||||
Reference in New Issue
Block a user