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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.