2015-02-09 79 views
1

我需要将csrf包含到我的项目中,而无需登录页面。所以我只在config xml中包含了以下内容。没有登录页面的CSRF弹簧实施页面

<security:http > 
 
     <security:csrf /> 
 
\t </security:http>

我收到以下错误。 org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:无法建立AuthenticationEntryPoint。请确保您有通过命名空间配置登录机制(如表单登录)或指定的“入口点-REF”自定义的AuthenticationEntryPoint属性

如何配置CSRF无需认证

回答

1

这最低配置应该工作:

<security:authentication-manager/> 
<security:http create-session="stateless" use-expressions="true"> 
    <security:csrf/> 
    <security:http-basic/> 
</security:http> 
+0

有错误已被删除。但是我的应用程序中找不到任何更改。我期待验证错误错误,因为我的表单中没有csrf标记。 – 2015-02-10 19:52:56

+0

适合我。你有没有将Spring Security过滤器添加到你的'web.xml'中? – manish 2015-02-13 04:47:11

+0

有一个可用的应用程序[这里](https://github.com/manish-in-java/spring-security-csrf)。 – manish 2015-02-13 05:17:38