【发布时间】:2012-09-27 13:19:39
【问题描述】:
我的 Spring 3.1 应用程序是这样配置的
<http use-expressions="true" entry-point-ref="http401UnauthorizedEntryPoint">
<intercept-url pattern="/app/demo" access="hasRole('Demo')" />
<intercept-url pattern="/app/**" access="isAuthenticated()" />
<intercept-url pattern="/admin/**" access="hasRole('Admin')" />
<custom-filter position="PRE_AUTH_FILTER"
ref="currentWindowsIdentityAuthenticationFilter" />
<logout invalidate-session="true" delete-cookies="JSESSIONID"
logout-url="/logout" logout-success-url="/logout-success" />
</http>
我已经编写了一个自定义的 preauth 过滤器。当我在根 URL / 调用我的应用程序时,过滤器链会挂接并运行 preauth 过滤器,尽管此资源不受保护。这意味着注销无法按设计工作。注销后再次执行登录。
我的实现基于org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter 类。
这是正常行为还是可以通过某种方式解决?我希望仅对受保护的 URL 执行身份验证。
顺便说一句,我不打算配置security='none',因为我想维护所有页面上的安全上下文。
我已在pastebin 上发布了相应的注销。太冗长了,这里就不介绍了。
【问题讨论】:
-
您可以打开调试(将
log4j.logger.org.springframework.security=DEBUG添加到log4j.properties 行)并在您的问题中发布输出吗? -
所以问题是:注销后再次登录。?
-
第二个问题:像
/other这样的其他资源是否应该通过PRE_AUTH_FILTER运行? -
第一个问题:是的,因为过滤器是在/**上执行的。第二个问题:不,只有
intercept-url定义的那些。据我所知,http匹配/并在其上应用整个链。
标签: spring spring-mvc configuration spring-security