This question might seems like duplicate but none of the below answers explained when to use:
`http
.authorizeRequests()
.antMatchers("/h2-console/**", "/user/register/**").permitAll()`
and
`web
.ignoring()
.antMatchers("/h2-console/**", "/user/register/**")`
- HttpSecurity, WebSecurity and AuthenticationManagerBuilder
- Difference between Web ignoring and Http permitting in Spring Security?
Going through StackOverflow asnwers and several articles I got to learn that:
configure(HttpSecurity) allows configuration of web based security at a resource level.
configure(WebSecurity) is used for configuration settings that impact global security. Using this a URL is completely ignored from Spring Security Filter Chain.
When i am using permitAll()
it only works if i have disabled csrf: http.csrf().disable()
because Spring Security filter chain is still active.
But with web.ignoring()
URL are ignored completely.
Still a lot of articles uses http.permitAll()
for /login
or /register
like like this one and this
So I want to understand,
Why should we even use http.permitAll()
at all for Un-Auth URLS like /login
and /register
?
Why can't we use web.ignoring()
for /login
and /register
?
Why web.ignoring()
is commonly used for serving static content like css
and webjars
etc only but not with /login
and /register
?