Consider changing this
http.apply(new JSONLoginConfigurer<HttpSecurity>()
.loginPage("/authenticate")
.successHandler(new SimpleUrlAuthenticationSuccessHandler("/dashboard"))
.permitAll());
to
JSONLoginConfigurer<HttpSecurity> configurer = new JSONLoginConfigurer<>();
configurer.setBuilder(http);
http.apply(configurer
.loginPage("/authenticate")
.successHandler(new SimpleUrlAuthenticationSuccessHandler("/dashboard"))
.permitAll());