Spring Boot - change locale on login page

i have a spring boot application with simple form login. The login works correctly.

http
    .authorizeRequests()
        .anyRequest().authenticated()
        .and()
    .formLogin()
        .loginPage("/login")
        .permitAll()
        .and()
    .logout()
        .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
        .logoutSuccessUrl("/login")
        .permitAll();

I also have internationalization through a CookieLocaleResolver and LocaleChangeInterceptor. This also works when logged in.

My Problem is:

The user can't change the locale while he is on the login page.

Login Page: https://localhost/login

Link to change the locale: https://localhost/login?locale=en

But the user is redirected again to https://localhost/login and locale stays the same.

Is there a way to allow parameters at the login page?

Thanks for your help!

Answers


Had the same problem, fixed with the following:

http
.authorizeRequests()
    .antMatchers("/login/**")//Basically I'm allowing parameters for login so locale can be added and read.
    .permitAll()
    .anyRequest()
    .fullyAuthenticated()
    .and()
.formLogin()
    .loginPage("/login")
    .permitAll()
    .and()
.logout()
    .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
    .logoutSuccessUrl("/login")
    .permitAll();

I think the problem has to do that when you change the locale this is send as a parameter and since the conf is not allowing for parameters withing /login it refreshes and shows the login page to try to authenticate you.


Need Your Help

Nix: Compile Vim with Ruby

ruby vim nix

I am using the Nix package manager on OS X. Let's say for the sake of argument I have a config.nix file that uses a pattern like so, allowing me to install the vimEnv no problem.

Webview in qr code scanner

android webview

class MyWebClient extends WebViewClient {