Home > Enterprise >  Spring Boot 3.0.2 adds "continue" query parameter to request URL after login
Spring Boot 3.0.2 adds "continue" query parameter to request URL after login

Time:01-26

I just upgraded my project from Spring boot 2.7.7 to 3.0.2 and I'm seeing some weird behavior. When I login to my application Spring adds "continue" query parameter to URL. It wasn't like this in 2.7.7. Is there something which I'm missing?

I use formLogin and have implemenatation of AuthenticationSuccessHandler, though it doesn't add any parameters.

enter image description here

CodePudding user response:

This is covered in Spring Security's migration guide.

Basically, the query parameter was added to make so that Spring Security knows whether to query the session on that request or not. It is a performance optimization.

You can change the value by configuring the RequestCache like so:

@Bean
SecurityFilterChain springSecurity(HttpSecurity http) throws Exception {
    HttpSessionRequestCache requestCache = new HttpSessionRequestCache();
    requestCache.setMatchingRequestParameterName("mycustomparameter");
    http
        // ...
        .requestCache((cache) -> cache
            .requestCache(requestCache)
        );
    return http.build();
}

Or, if you don't want this performance optimization, you can turn it off in the same way:

@Bean
SecurityFilterChain springSecurity(HttpSecurity http) throws Exception {
    HttpSessionRequestCache requestCache = new HttpSessionRequestCache();
    requestCache.setMatchingRequestParameterName(null);
    http
        // ...
        .requestCache((cache) -> cache
            .requestCache(requestCache)
        );
    return http.build();
}
  • Related