-1

I am not used to working with Spring Security. I have been trying the below code;

 http.authorizeRequests()
        .antMatchers("/health", "/info")
        .access("hasIpAddress('X.X.X.X') or hasIpAddress('Y.Y.Y.Y')")

I want to allow some of my endpoints to all users like /health or /info from Spring and want to restrict other endpoints to requests from a few IP only. I tried something like above, but it didn't work. How to achieve, if possible, what I am trying to do with Spring Security?

Amit
  • 451
  • 1
  • 6
  • 19

1 Answers1

1

code above works perfectly. Sorry , it was my mac issue returning ipV6 so that it was looking like it is failing.

Anyone wanting to restrict only with ip can use code above, it is better than using xml.

Amit
  • 451
  • 1
  • 6
  • 19