refactor: 发送验证码代码重构优化;扩展Spring Security 支持短信验证码;

This commit is contained in:
Ray.Hao
2025-01-13 18:14:52 +08:00
parent b107bb5315
commit 4ecb25147f
39 changed files with 457 additions and 362 deletions

View File

@@ -7,7 +7,8 @@ import com.youlai.boot.config.property.SecurityProperties;
import com.youlai.boot.core.filter.RateLimiterFilter;
import com.youlai.boot.core.security.exception.MyAccessDeniedHandler;
import com.youlai.boot.core.security.exception.MyAuthenticationEntryPoint;
import com.youlai.boot.core.security.extension.WechatAuthenticationProvider;
import com.youlai.boot.core.security.extension.sms.SmsAuthenticationProvider;
import com.youlai.boot.core.security.extension.wechat.WechatAuthenticationProvider;
import com.youlai.boot.core.security.filter.CaptchaValidationFilter;
import com.youlai.boot.core.security.filter.JwtAuthenticationFilter;
import com.youlai.boot.core.security.service.SysUserDetailsService;
@@ -131,6 +132,10 @@ public class SecurityConfig {
return new WechatAuthenticationProvider(userService, wxMaService);
}
public SmsAuthenticationProvider smsAuthenticationProvider() {
return new SmsAuthenticationProvider(userService, redisTemplate);
}
/**
* 手动注入 AuthenticationManager支持多种认证方式
* - DaoAuthenticationProvider用户名密码认证
@@ -138,6 +143,10 @@ public class SecurityConfig {
*/
@Bean
public AuthenticationManager authenticationManager() {
return new ProviderManager(daoAuthenticationProvider(), weChatAuthenticationProvider());
return new ProviderManager(
daoAuthenticationProvider(),
weChatAuthenticationProvider(),
smsAuthenticationProvider()
);
}
}