Skip to content

Commit 8091152

Browse files
committed
修改依赖,优化前后端分离token处理机制,
前后端项目增加移除session
1 parent f597e8e commit 8091152

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
<dependency>
171171
<groupId>com.fasterxml.jackson.core</groupId>
172172
<artifactId>jackson-databind</artifactId>
173-
<version>2.9.8</version>
173+
<version>2.9.9</version>
174174
</dependency>
175175

176176
<dependency>

src/main/java/com/geekcattle/core/security/WebSecurityConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.springframework.security.config.annotation.web.builders.WebSecurity;
1212
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
1313
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
14+
import org.springframework.security.config.http.SessionCreationPolicy;
1415
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
1516
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1617
import org.springframework.security.web.firewall.HttpFirewall;
@@ -67,7 +68,10 @@ public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
6768
*/
6869
@Override
6970
protected void configure(HttpSecurity http) throws Exception {
70-
http.authorizeRequests()
71+
http.csrf().disable()
72+
//如果项目是前后端分离,可将取消该行注释
73+
//.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
74+
.authorizeRequests()
7175
//注册端口开启
7276
.antMatchers("/member/reg","/api/**").permitAll()
7377
//会员中心的相关操作必需登录才可访问
@@ -81,7 +85,6 @@ protected void configure(HttpSecurity http) throws Exception {
8185
.and().logout().logoutUrl("/member/logout").logoutSuccessUrl("/").permitAll();
8286
http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
8387
//关闭csrf 防止循环定向
84-
http.csrf().disable();
8588
}
8689

8790

0 commit comments

Comments
 (0)