Chrome stored data - spring security login form hangs indefinitely

Viewed 479

Google chrome [EDIT] Version 80.0.3987.162 (Official Build) (64-bit)[/EDIT] waits for a response indefinitely when trying to login to my spring security web app.

I managed to produce this error with a simple demo app using spring initialzr with these specs:

  • spring boot 2.2.6
  • spring web
  • spring boot devtools
  • spring security

The only thing I added, was a simple WebSecurityConfigurerAdapter

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    private final MyUserDetailsService userDetailsService;

    @Autowired
    public WebSecurityConfig(final MyUserDetailsService userDetailsService) {
        this.userDetailsService = userDetailsService;
    }


    @Override
    protected void configure(final HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/login").permitAll()
                .antMatchers("/css/**").permitAll()
                .antMatchers("/js/**").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .permitAll()
                .and()
                .logout().permitAll();
    }

    @Autowired
    public void globalSecurityConfiguration(AuthenticationManagerBuilder auth) throws Exception {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        auth
                .userDetailsService(userDetailsService)
                .passwordEncoder(encoder);
    }
}

and a UserDetailsService

@Service
public class MyUserDetailsService implements UserDetailsService {

//  @Autowired
//  private UserRepository userRepository;

        public MyUserDetailsService() {
        }

        @Override
        public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException {
            return getUserTestStyle();
        }

        private UserDetails getUserTestStyle() {
            return new MyUser("admin", "SimplePassword#");
        }
}

I see that in devtools, the login-POST-Request stays on Pending, even after the server has fully processed the login-request (and confirms in DEBUG-log that authentication was successful).

Things I observed and confirmed:

  • the server authentication is successful (even though the browser does not redirect) (i can access secured URLs as soon as the server processed the login-request)
  • this happens only on the very first login-attempt when Chrome has been freshly opened (but when doing so, the issue happens every time)
  • the problem does not occur, when I change the password on the server side, and enter the changed password on the client
  • the problem has been gone after I completely cleared all my browser data (CTRL+SHIFT+DEL)
  • this problem is chrome-specific, I cannot reproduce this with Firefox or Microsoft Edge
0 Answers
Related