I am using Spring Boot,Spring MVC and Spring Security. I added JWT authorization so i need to make my application Session Stateless, so i added corresponding parameter to my Security Config:
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
But when I make any request to my app i get JSESSIONID as cookie. I tried to solve the problem by adding this code to my jwt filter:
Cookie[] cookies = httpServletRequest.getCookies();
if(cookies!=null)
for (int i = 0; i < cookies.length; i++) {
cookies[i].setMaxAge(0);
httpServletResponse.addCookie(cookies[i]);
}
But it did not help, so how to finally remove it ??
My full security code:
@Override
public void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.authorizeRequests()
.antMatchers("/user/login").permitAll().antMatchers("/user/get/**").hasRole(Role.BOT.toString()).antMatchers("/", "/login**","/callback/", "/webjars/**", "/error**")
.permitAll().anyRequest().authenticated();
http.apply(new JwtFilterConfiguer(provider));
}