|
@@ -66,13 +66,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(SecurityConfig.class);
|
|
|
|
|
|
- @Value("${jwt.header}")
|
|
|
+ @Value("${jwt.header:X-Token}")
|
|
|
private String tokenHeader;
|
|
|
|
|
|
- @Value("${jwt.cookie}")
|
|
|
+ @Value("${jwt.cookie:X-Cookie}")
|
|
|
private String cookieName;
|
|
|
|
|
|
- @Value("${jwt.expiration}")
|
|
|
+ @Value("${jwt.expiration:604800}")
|
|
|
private Integer expiration;
|
|
|
|
|
|
@Autowired
|
|
@@ -155,7 +155,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
.anyRequest().authenticated()
|
|
|
.and().csrf().disable()
|
|
|
.authorizeRequests().antMatchers("/login", "/logout", "/favicon.ico", "/error", "/file/**").permitAll()
|
|
|
- .and().addFilterBefore(jwtAuthenticationTokenFilter, SessionManagementFilter.class);
|
|
|
+// .and().addFilterBefore(jwtAuthenticationTokenFilter, SessionManagementFilter.class);
|
|
|
+ .and().addFilter(jwtAuthenticationTokenFilter);
|
|
|
|
|
|
http
|
|
|
.formLogin().successHandler(new RestAuthenticationSuccessHandler())
|
|
@@ -163,10 +164,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
.permitAll()
|
|
|
.and()
|
|
|
.logout().logoutSuccessHandler(new RestLogoutSuccessHandler())
|
|
|
- .deleteCookies("JSESSIONID", "JWT_TOKEN")
|
|
|
+// .deleteCookies("JSESSIONID", "JWT_TOKEN")
|
|
|
.permitAll();
|
|
|
//session 管理
|
|
|
- http.sessionManagement().maximumSessions(5);
|
|
|
+// http.sessionManagement().maximumSessions(5);
|
|
|
|
|
|
http.exceptionHandling().authenticationEntryPoint(new RestAuthenticationEntryPoint());
|
|
|
|
|
@@ -256,7 +257,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
throws IOException, ServletException {
|
|
|
|
|
|
logger.info("登出成功! ");
|
|
|
- HttpUtil.delCookies(request, response, "JSESSIONID", cookieName);
|
|
|
+ HttpUtil.delCookies(request, response, cookieName);
|
|
|
HttpUtil.ok(request, response);
|
|
|
|
|
|
}
|