I am trying to use url (ant) matching with @PreAuthorize ("allowAll") on some ie controllers
@Controller @RequestMapping("/register") public class RegistrationController { ... @PreAuthorize("permitAll") @RequestMapping(method = RequestMethod.GET) public String register() { ... }
SecurityConfig:
@Configuration @EnableWebMvcSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception {
I also tried adding @EnableGlobalMethodSecurity to my MVC configuration:
@Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) public class MvcConfig extends WebMvcConfigurerAdapter { ... }
But it has no effect
However, I am still invited to authenticate when clicked / registered. If I add "/ register" to ant matches, it works, that is .antMatchers ("/", "/ register"). AllowAll ()
What am I missing here? It seems that @PreAuthorize does not affect my controllers.
source share