I currenty can't make any calls to my rest api implemented in spring boot using spring security. I get the following message:
{
"timestamp": "2019-09-08T10:24:35.020+0000",
"status": 500,
"error": "Internal Server Error",
"message": "Session support is not enabled in appengine-web.xml. To enable sessions, put <sessions-enabled>true</sessions-enabled> in that file. Without it, getSession() is allowed, but manipulation of sessionattributes is not.",
"path": "/login"
}
I explicitly stated in the security config to not use sessions (as stated in this stackoverflow question). what else do I need to do to use app engine without sessions?:
security config:
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
WebTokenAuthenticationService webTokenAuthenticationService;
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf().disable();
httpSecurity.authorizeRequests()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.antMatchers(LOGIN_ROUTE).permitAll()
.antMatchers(DATA).hasAnyAuthority(Authority.admin.toString())
.and()
.addFilterBefore(new AuthenticationTokenFilter(webTokenAuthenticationService), UsernamePasswordAuthenticationFilter.class)
;
httpSecurity.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
}
authentificationTokenFilter
public class AuthenticationTokenFilter extends GenericFilterBean {
private WebTokenAuthenticationService webTokenAuthenticationService;
public AuthenticationTokenFilter(WebTokenAuthenticationService webTokenAuthenticationService) {
this.webTokenAuthenticationService = webTokenAuthenticationService;
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
Authentication authentication = webTokenAuthenticationService.authenticate(httpRequest);
SecurityContextHolder.getContext().setAuthentication(authentication);
filterChain.doFilter(servletRequest, servletResponse);
SecurityContextHolder.getContext().setAuthentication(null);
}
}