2015-03-19 151 views
0

我想禁用服務器上的Trace動詞,以便端點無法追蹤。Spring MVC跟蹤Http請求

我的端點使用Spring MVC和有一個選項endpoints.trace.enabled=false.

疼痛是如何測試這一點,如果跟蹤被禁用或不創建。我嘗試了Chrome插件實時HTTP標題,但它用於通用網站。我想檢查我的端點。

例如:

捲曲--insecure -v -X TRACE -H http://localhost:8080/toy/49f6a7d3-eb20-3ab2-be3b-8399e7f28abf

HTTP/1.1 200 OK 
< Date: Sat, 21 Mar 2015 04:34:03 GMT 
< Content-Type: message/http; charset=UTF-8 
< Content-Length: 270 
< 
TRACE /toy/49f6a7d3-eb20-3ab2-be3b-8399e7f28abf HTTP/1.1 
User-Agent: curl/7.37.1 
Host: localhost:8080 
Accept: */* 
* Connection #0 to host localhost left intact 

下面我嘗試,但現在它拒絕所有的請求。

@Configuration 
@EnableWebMvcSecurity 
@EnableGlobalMethodSecurity(securedEnabled=true, prePostEnabled = true, jsr250Enabled = true) 
public class SecurityConfig extends WebSecurityConfigurerAdapter { 
    @Override 
    protected void configure(HttpSecurity http) throws Exception { 
     http.requestMatchers() 
       .and() 
       .csrf().disable() 
       .authorizeRequests() 
       .antMatchers(HttpMethod.TRACE, "/**").denyAll(); 
    } 
} 

回答

0

AFAIK TRACE默認情況下,在Tomcat上,以及碼頭6禁用,

您可以使用捲曲,以確保:

curl -v -X TRACE http://www.example.com

你想看到405 method not allowed響應。

+0

我們在Spring MVC中使用jetty inbuild。 – plzdontkillme 2015-03-19 05:19:21

+0

對於使用哪個應用程序服務器或容器來說,捲曲並不重要。重要的部分是你可以用這種你想要的方式輕鬆地看到答案。 – erhun 2015-03-19 09:21:57

+0

@plzdontkillme你需要告訴我們你正在使用什麼版本的Jetty。不要害羞 – 2015-03-22 01:20:59