Search code examples
springspring-bootwebsecurity

SpringBoot websecurity doesn't ignore a url if it has params


I was trying to ignore a url from WebSecurity in SpringBoot. Was able to do it for exact url match. But if there is a param in the url itself, it couldn't ignore it. Is there a better way to ignore a url, like ignoring a particular controller. And if not, how to work around with params?

@Override
public void configure(WebSecurity web) throws Exception {
    web.ignoring().antMatchers("/api/v1/something");
    // was able to ignore [url]/api/v1/something but not [url]/api/v1/something?xyz=wjsbjbjbsjbw
}

Solution

  • web.ignoring().antMatchers("/api/v1/something/**"); should work fine but do check if you had included web.ignoring().antMatchers("/error/**"); as i was facing similar issue earlier, error endpoints were also getting authenticated . hope this helps.