I am trying to apply URl and role based authentication in the following way
http
.authorizeRequests()
.antMatchers("/rest/**").hasRole("ADMIN")
.and()
.authorizeRequests()
.antMatchers("/admin/**").hasRole("MANAGER")
.and()
.authorizeRequests()
.antMatchers("/restApi/**").hasRole("USER")
.anyRequest().authenticated()
.and()
.formLogin()
.permitAll();
But after entering username and password, I am getting back default login screen provided by Spring Boot.
If I use permitAll()
instead of hasRole()
, then it works correctly.
Where am I wrong?