Skip to content

Instantly share code, notes, and snippets.

@debedb
Last active December 12, 2021 09:39
Show Gist options
  • Save debedb/4b47ed9f355d9124cc1743a89421ee8f to your computer and use it in GitHub Desktop.
Save debedb/4b47ed9f355d9124cc1743a89421ee8f to your computer and use it in GitHub Desktop.

Answer to https://stackoverflow.com/questions/35687148/how-to-make-spring-security-accept-json-instead-of-form-parameters#comment96085391_54271048:

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());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment