How to do it...

Let us now implement another security model that uses a custom authentication process instead of the default:

  1. First, create a new security context definition, AppSecurityModelB, which presents the overriding of the http.formLogin().loginProcessingUrl() and the customization of the authentication manager and its providers:
@Configuration @EnableWebSecurity public class AppSecurityModelB extends WebSecurityConfigurerAdapter{ @Autowired private AuthenticationProvider appAdminProvider; @Autowired private AuthenticationProvider appHRProvider; @Autowired private AuthenticationManager appAuthenticationMgr; @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { } @Override protected void configure(HttpSecurity ...

Get Spring 5.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.