access =“permitAll”和filters =“none”之间的区别?

时间:2011-09-12 17:39:49

标签: java spring spring-security

以下是Spring Security petclinic示例的一部分:

<http use-expressions="true">
    <intercept-url pattern="/" access="permitAll"/>
    <intercept-url pattern="/static/**" filters="none" />
    <intercept-url pattern="/**" access="isAuthenticated()" />
    <form-login />
    <logout />
</http>

access =“permitAll”和filters =“none”之间有什么区别?

网址: http://static.springsource.org/spring-security/site/petclinic-tutorial.html

1 个答案:

答案 0 :(得分:31)

不同之处在于filters = "none"会禁用指定网址的Spring Security过滤器,而access = "permitAll"会在不禁用过滤器的情况下配置授权。

实际上,当filters = "none"背后的资源需要Spring Security的某些功能时,{{1}}可能会导致问题。例如,您不能将其用于在提交(User Granted Authorities are always : ROLE_ANONYMOUS?)上执行程序化登录的用户注册页面。