Issue
I have setup a spring resource server using Spring 5. All my endpoints now require a valid access token. How can I allow my /health endpoint free access? With below configuration, it does not work and health endpoint also requires an access token.
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/health").permitAll()
.antMatchers("/user").authenticated()
.and().formLogin()
.and().requestMatchers()
.antMatchers("/oauth/authorize");
}
Solution
After a lot of research, I added this small piece of code to make it work like a charm.
@Override
public void configure(WebSecurity web) {
web.ignoring().antMatchers("/user");
}
Answered By - Gauranga Rathod
Answer Checked By - Katrina (JavaFixing Volunteer)