簡體   English   中英

Spring Security禁用從特定URL發出的請求的安全性

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

我的應用程序使用Spring Security。 我知道您可以使用antMatchers來允許請求一些映射到您的應用程序中的URI。 但是我也需要允許從外部api向我的應用程序中的URI發出請求,並且僅針對該api。 我需要這樣的東西:

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

有人知道這是否可能嗎? 我沒有找到任何東西。

您可以執行以下操作(如果要合並多個條件)

.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')")

要么

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM