jso*_*ski 6 java spring cas spring-security jasig
我使用Apereo CAS(以前的Jasig CAS)(这里是github).接下来,我在Vaadin中创建了一个非常简单的应用程序,它在身份验证期间连接到CAS.一切都无缝地工作,直到我从Spring Security开启CSRF.
如果打开CSRF,则重定向到CAS登录页面可以正常工作.但是在成功验证(登录,passoword)之后,CAS想要重定向回我的应用程序.然后我看到了这个:
{
"timestamp": 1498657046424,
"status": 403,
"error": "Forbidden",
"message": "Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-XSRF-TOKEN'.",
"path": "/contextPath/"
}
Run Code Online (Sandbox Code Playgroud)
我使用Spring Boot @EnableWebSecurity,所以请从那里看一下配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.addFilter(casAuthenticationFilter())
.addFilterBefore(singleSignOutFilter(), CasAuthenticationFilter.class)
.exceptionHandling()
.authenticationEntryPoint(casAuthenticationEntryPoint())
.and()
.authorizeRequests()
.antMatchers("/login")
.permitAll()
.anyRequest()
.authenticated();
http.csrf().disable(); //works when disable
}
Run Code Online (Sandbox Code Playgroud)
我的问题: 如何使用CAS身份验证配置Spring Security以使CSRF正常工作?
我正在使用Spring Boot 1.5.4.RELEASE(maven parent)和Vaadin 8.0.5(BOM).