|
|
@@ -20,6 +20,8 @@ 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.authentication.UsernamePasswordAuthenticationFilter;
|
|
|
+import org.springframework.web.cors.CorsConfiguration;
|
|
|
+import org.springframework.web.cors.CorsConfigurationSource;
|
|
|
import org.springframework.web.cors.CorsUtils;
|
|
|
import seecoder.devcloud.web.infrastructure.security.JwtAuthenticationTokenFilter;
|
|
|
import seecoder.devcloud.web.infrastructure.security.WebSecurityConstants;
|
|
|
@@ -45,6 +47,8 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
|
|
|
private final JwtAuthenticationTokenFilter filter;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Autowired
|
|
|
public WebSecurityConfig(JwtAuthenticationTokenFilter filter) {
|
|
|
super();
|
|
|
@@ -89,6 +93,20 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
return super.authenticationManagerBean() ;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 本地测试时的跨域设置
|
|
|
+ */
|
|
|
+ @Bean
|
|
|
+ CorsConfigurationSource corsConfigurationSource(){
|
|
|
+ return httpServletRequest -> {
|
|
|
+ CorsConfiguration cfg = new CorsConfiguration();
|
|
|
+ cfg.addAllowedHeader("*");
|
|
|
+ cfg.addAllowedMethod("*");
|
|
|
+ cfg.addAllowedOrigin("http://localhost:3000");
|
|
|
+ cfg.setAllowCredentials(true);
|
|
|
+ cfg.checkOrigin("http://localhost:3000");
|
|
|
+ return cfg;
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
}
|