简体   繁体   English

Spring Security禁用从特定URL发出的请求的安全性

[英]Spring Security disable security for requests made FROM a certain url

my application uses spring security. 我的应用程序使用Spring Security。 I know you can use antMatchers to permit requests for some URI that are mapped into your application. 我知道您可以使用antMatchers来允许请求一些映射到您的应用程序中的URI。 But I need too allow requests made from an external api to a URI in my application and just for that api. 但是我也需要允许从外部api向我的应用程序中的URI发出请求,并且仅针对该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");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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