|
|
|
@ -8,18 +8,29 @@ |
|
|
|
package com.depsystem.app.systemServer.config; |
|
|
|
package com.depsystem.app.systemServer.config; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
import com.depsystem.app.systemServer.securityServer.securityFilter.AuthenticationServerImpl; |
|
|
|
|
|
|
|
import com.depsystem.app.systemServer.securityServer.handler.AuthenticationsFailureHandler; |
|
|
|
|
|
|
|
import com.depsystem.app.systemServer.securityServer.handler.AuthenticationsSuccessHandler; |
|
|
|
|
|
|
|
======= |
|
|
|
import com.depsystem.app.systemServer.securityServer.AuthenticationServerImpl; |
|
|
|
import com.depsystem.app.systemServer.securityServer.AuthenticationServerImpl; |
|
|
|
import com.depsystem.app.systemServer.securityServer.handler.AuthenticationsFailureHandler; |
|
|
|
import com.depsystem.app.systemServer.securityServer.handler.AuthenticationsFailureHandler; |
|
|
|
import com.depsystem.app.systemServer.securityServer.handler.AuthenticationsSuccessHandler; |
|
|
|
import com.depsystem.app.systemServer.securityServer.handler.AuthenticationsSuccessHandler; |
|
|
|
import com.depsystem.app.systemServer.securityServer.securityFilter.CaptchaVerifyFilter; |
|
|
|
import com.depsystem.app.systemServer.securityServer.securityFilter.CaptchaVerifyFilter; |
|
|
|
|
|
|
|
>>>>>>> 024d1f4 (最新版Spring boot + Vue3 + Spring Security 6 项目模板) |
|
|
|
import com.depsystem.app.systemServer.util.ResponseResult; |
|
|
|
import com.depsystem.app.systemServer.util.ResponseResult; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import jakarta.annotation.Resource; |
|
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
|
import jakarta.servlet.http.HttpServletRequest; |
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
|
|
|
======= |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
|
|
|
|
|
>>>>>>> 024d1f4 (最新版Spring boot + Vue3 + Spring Security 6 项目模板) |
|
|
|
import org.springframework.security.authentication.AuthenticationManager; |
|
|
|
import org.springframework.security.authentication.AuthenticationManager; |
|
|
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
|
|
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
@ -28,11 +39,15 @@ import org.springframework.security.core.AuthenticationException; |
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder; |
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder; |
|
|
|
import org.springframework.security.web.SecurityFilterChain; |
|
|
|
import org.springframework.security.web.SecurityFilterChain; |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
======= |
|
|
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
|
|
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
|
|
|
|
|
|
|
>>>>>>> 024d1f4 (最新版Spring boot + Vue3 + Spring Security 6 项目模板) |
|
|
|
import org.springframework.web.cors.CorsConfiguration; |
|
|
|
import org.springframework.web.cors.CorsConfiguration; |
|
|
|
import org.springframework.web.cors.CorsConfigurationSource; |
|
|
|
import org.springframework.web.cors.CorsConfigurationSource; |
|
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
|
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -43,9 +58,12 @@ public class WebSecurityConfig { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
AuthenticationServerImpl authenticationServer; |
|
|
|
AuthenticationServerImpl authenticationServer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
======= |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
StringRedisTemplate stringRedisTemplate; |
|
|
|
StringRedisTemplate stringRedisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>>>>>>> 024d1f4 (最新版Spring boot + Vue3 + Spring Security 6 项目模板) |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public AuthenticationManager authenticationManager(HttpSecurity httpSecurity) throws Exception { |
|
|
|
public AuthenticationManager authenticationManager(HttpSecurity httpSecurity) throws Exception { |
|
|
|
return httpSecurity.userDetailsService(authenticationServer) |
|
|
|
return httpSecurity.userDetailsService(authenticationServer) |
|
|
|
@ -58,6 +76,11 @@ public class WebSecurityConfig { |
|
|
|
http.authorizeHttpRequests(author -> |
|
|
|
http.authorizeHttpRequests(author -> |
|
|
|
author |
|
|
|
author |
|
|
|
.requestMatchers("/captcha").permitAll() |
|
|
|
.requestMatchers("/captcha").permitAll() |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
.requestMatchers("/index").hasAnyRole("admin1") |
|
|
|
|
|
|
|
.requestMatchers("/{name}/**").hasAnyRole("admin2","admin3") |
|
|
|
|
|
|
|
======= |
|
|
|
|
|
|
|
>>>>>>> 024d1f4 (最新版Spring boot + Vue3 + Spring Security 6 项目模板) |
|
|
|
.anyRequest().authenticated() |
|
|
|
.anyRequest().authenticated() |
|
|
|
) |
|
|
|
) |
|
|
|
.formLogin() |
|
|
|
.formLogin() |
|
|
|
@ -74,7 +97,10 @@ public class WebSecurityConfig { |
|
|
|
.csrf().disable() |
|
|
|
.csrf().disable() |
|
|
|
.exceptionHandling() |
|
|
|
.exceptionHandling() |
|
|
|
.authenticationEntryPoint(this::onAuthenticationFailure); |
|
|
|
.authenticationEntryPoint(this::onAuthenticationFailure); |
|
|
|
|
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
======= |
|
|
|
http.addFilterBefore(new CaptchaVerifyFilter(this::onAuthenticationFailure,stringRedisTemplate), UsernamePasswordAuthenticationFilter.class); |
|
|
|
http.addFilterBefore(new CaptchaVerifyFilter(this::onAuthenticationFailure,stringRedisTemplate), UsernamePasswordAuthenticationFilter.class); |
|
|
|
|
|
|
|
>>>>>>> 024d1f4 (最新版Spring boot + Vue3 + Spring Security 6 项目模板) |
|
|
|
return http.build(); |
|
|
|
return http.build(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|