|
|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.framework.config;
|
|
|
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.framework.config.properties.PermitAllUrlProperties;
|
|
|
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
|
|
|
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
|
|
|
@@ -15,6 +16,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
+import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.security.web.SecurityFilterChain;
|
|
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
|
import org.springframework.security.web.authentication.logout.LogoutFilter;
|
|
|
@@ -63,9 +65,12 @@ public class SecurityConfig {
|
|
|
@Autowired
|
|
|
private PermitAllUrlProperties permitAllUrl;
|
|
|
|
|
|
- /**
|
|
|
+/*
|
|
|
+ */
|
|
|
+/**
|
|
|
* 身份验证实现
|
|
|
- */
|
|
|
+ *//*
|
|
|
+
|
|
|
@Bean
|
|
|
public AuthenticationManager authenticationManager() {
|
|
|
DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
|
|
|
@@ -73,6 +78,36 @@ public class SecurityConfig {
|
|
|
daoAuthenticationProvider.setPasswordEncoder(bCryptPasswordEncoder());
|
|
|
return new ProviderManager(daoAuthenticationProvider);
|
|
|
}
|
|
|
+*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 身份验证实现 - 使用 SM3 密码编码器
|
|
|
+ */
|
|
|
+ @Bean
|
|
|
+ public AuthenticationManager authenticationManager() {
|
|
|
+ DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
|
|
|
+ daoAuthenticationProvider.setUserDetailsService(userDetailsService);
|
|
|
+ daoAuthenticationProvider.setPasswordEncoder(sm3PasswordEncoder()); // 改为 SM3 编码器
|
|
|
+ return new ProviderManager(daoAuthenticationProvider);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SM3 密码编码器 Bean
|
|
|
+ */
|
|
|
+ @Bean
|
|
|
+ public PasswordEncoder sm3PasswordEncoder() {
|
|
|
+ return new PasswordEncoder() {
|
|
|
+ @Override
|
|
|
+ public String encode(CharSequence rawPassword) {
|
|
|
+ return SecurityUtils.encryptPassword(rawPassword.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean matches(CharSequence rawPassword, String encodedPassword) {
|
|
|
+ return SecurityUtils.matchesPassword(rawPassword.toString(), encodedPassword);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* anyRequest | 匹配所有请求路径
|