简体   繁体   中英

Spring Security disable security for requests made FROM a certain url

my application uses spring security. I know you can use antMatchers to permit requests for some URI that are mapped into your application. But I need too allow requests made from an external api to a URI in my application and just for that api. I need something like this:

     @Override
     protected void configure(WebSecurity web) throws Exception 
     {            
        web.ignoring()
          .antMatchers("http://externalTestApi.com");
     }

Does anybody know if this is possible? I did not find anything on this.

You can do something like this (if you want to combine multiple conditions)

.authorizeRequests()
.antMatchers("/user/list")
.access("authenticated or hasIpAddress('666.666.666.666') or hasIpAddress('127.0.0.1') or hasIpAddress('0:0:0:0:0:0:0:1')")

or

.authorizeRequests()
.antMatchers("/user/list")
.hasIpAddress("0.0.0.0/0");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM