From 2040bac6c6e71f585d4cec0a06eed7d7302ba7a6 Mon Sep 17 00:00:00 2001 From: wwan13 Date: Wed, 26 Jun 2024 14:48:18 +0900 Subject: [PATCH] fix : PasswordEncoder providing error --- .../config/AuthConfiguration.java | 5 +++-- .../passwordencoder/PasswordEncoder.java | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java b/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java index 275ead8..c193116 100644 --- a/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java +++ b/src/main/java/io/wwan13/wintersecurity/config/AuthConfiguration.java @@ -25,10 +25,11 @@ import io.wwan13.wintersecurity.auth.provider.HttpRequestAccessManager; import io.wwan13.wintersecurity.jwt.TokenDecoder; import io.wwan13.wintersecurity.jwt.provider.JwtTokenDecoder; +import io.wwan13.wintersecurity.passwordencoder.PasswordEncoder; import io.wwan13.wintersecurity.secretkey.SecretKey; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; -import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; public class AuthConfiguration { @@ -63,6 +64,6 @@ public AbstractInterceptorAuthProcessor authProcessor( @Bean public PasswordEncoder passwordEncoder() { - return new io.wwan13.wintersecurity.passwordencoder.PasswordEncoder(); + return new PasswordEncoder(new BCryptPasswordEncoder()); } } diff --git a/src/main/java/io/wwan13/wintersecurity/passwordencoder/PasswordEncoder.java b/src/main/java/io/wwan13/wintersecurity/passwordencoder/PasswordEncoder.java index 346095a..cf83802 100644 --- a/src/main/java/io/wwan13/wintersecurity/passwordencoder/PasswordEncoder.java +++ b/src/main/java/io/wwan13/wintersecurity/passwordencoder/PasswordEncoder.java @@ -18,5 +18,23 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -public class PasswordEncoder extends BCryptPasswordEncoder { +public class PasswordEncoder { + + private final BCryptPasswordEncoder bCryptPasswordEncoder; + + public PasswordEncoder(BCryptPasswordEncoder bCryptPasswordEncoder) { + this.bCryptPasswordEncoder = bCryptPasswordEncoder; + } + + public String encode(CharSequence rawPassword) { + return bCryptPasswordEncoder.encode(rawPassword); + } + + public boolean matches(CharSequence rawPassword, String encodedPassword) { + return bCryptPasswordEncoder.matches(rawPassword, encodedPassword); + } + + public boolean upgradeEncoding(String encodedPassword) { + return bCryptPasswordEncoder.upgradeEncoding(encodedPassword); + } }