或者它是否发现了设计问题?
要决定是否应该在我的自定义 AuthenticationFilter
中继续过滤器链,我需要检查 Authentication
是否是 AnonymousAuthenticationToken
以及当前匹配的 URL 是否具有 access="permitAll"
属性(通常由 FilterSecurityInterceptor
处理)。
所以
<!-- chain should continue past authentication regardless of authentication type (anonymous/actual) -->
<security:intercept-url pattern="/pages/public/public.html" access="permitAll"/>
<!-- chain should continue only on non-anonymous authentication -->
<security:intercept-url pattern="/pages/authenticated/stuff.html" access="isAuthenticated()"/>
换句话说,我需要一种方法来识别应该跳过身份验证的 URL 路径,但仍然拥有匿名 token ,以便安全拦截器照常工作。
我使用的是 Spring Security 3.0.1,因此目前无法选择针对不同 URL 路径使用单独的过滤器链。
最佳答案
嗯,你正在混合身份验证和授权,所以这肯定是一种味道。执行access="IS_AUTHENTICATED_ANONYMOUSLY"
有什么问题?
关于java - Spring Security 中的 AuthenticationFilter 中需要 "normal"是 `ConfigurationAttribute` 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9197154/