2015-10-16 123 views
0

林本指南https://spring.io/guides/gs/securing-web/guide成立春季安全爲我的微服務春季安全POST請求以下

我只是發送基本POST和GET請求。我能做的GET請求,但是當我嘗試POST請求我得到一個403錯誤。(「預期CSRF令牌沒有發現。貴國會話過期?」) 我試着去建立基本身份驗證我的microService

感謝

回答

1

默認情況下啓用csrf保護。您必須將所有頁面配置爲包含_csrf令牌才能運行 請參見:CSRF Spring docs

您可以始終禁用csrf保護。 如果配置在代碼:

@EnableWebSecurity 
public class WebSecurityConfig extends 
WebSecurityConfigurerAdapter { 

@Override 
protected void configure(HttpSecurity http) throws Exception { 
http 
.csrf().disable(); 
} 
} 

或XML:

<http> 
    <!-- ... --> 
    <csrf disabled="true"/> 
</http>