File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
src/main/java/com/geekcattle/core/security Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 170
170
<dependency >
171
171
<groupId >com.fasterxml.jackson.core</groupId >
172
172
<artifactId >jackson-databind</artifactId >
173
- <version >2.9.8 </version >
173
+ <version >2.9.9 </version >
174
174
</dependency >
175
175
176
176
<dependency >
Original file line number Diff line number Diff line change 11
11
import org .springframework .security .config .annotation .web .builders .WebSecurity ;
12
12
import org .springframework .security .config .annotation .web .configuration .EnableWebSecurity ;
13
13
import org .springframework .security .config .annotation .web .configuration .WebSecurityConfigurerAdapter ;
14
+ import org .springframework .security .config .http .SessionCreationPolicy ;
14
15
import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
15
16
import org .springframework .security .web .authentication .UsernamePasswordAuthenticationFilter ;
16
17
import org .springframework .security .web .firewall .HttpFirewall ;
@@ -67,7 +68,10 @@ public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
67
68
*/
68
69
@ Override
69
70
protected void configure (HttpSecurity http ) throws Exception {
70
- http .authorizeRequests ()
71
+ http .csrf ().disable ()
72
+ //如果项目是前后端分离,可将取消该行注释
73
+ //.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
74
+ .authorizeRequests ()
71
75
//注册端口开启
72
76
.antMatchers ("/member/reg" ,"/api/**" ).permitAll ()
73
77
//会员中心的相关操作必需登录才可访问
@@ -81,7 +85,6 @@ protected void configure(HttpSecurity http) throws Exception {
81
85
.and ().logout ().logoutUrl ("/member/logout" ).logoutSuccessUrl ("/" ).permitAll ();
82
86
http .addFilterBefore (jwtAuthenticationFilter (), UsernamePasswordAuthenticationFilter .class );
83
87
//关闭csrf 防止循环定向
84
- http .csrf ().disable ();
85
88
}
86
89
87
90
You can’t perform that action at this time.
0 commit comments