【发布时间】:2012-01-20 12:10:06
【问题描述】:
我遇到了双重身份验证问题。我已经通过始终位于顶部的弹出窗口实现了身份验证表单。但是我可能在应用程序启动之前就导致 Tomcat 进行身份验证请求的拦截器有问题:
http://127.0.0.1:8888 正在请求用户名和密码。 该网站说:“Spring Security Application”
如果我禁用拦截器,我会在日志中看到 SecurityContextHolder 将用户视为匿名用户。
所以我的问题是: 我可以以某种方式禁用第一个 Tomcat 登录屏幕吗?
我的 Spring-security 配置 XML 是:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<authentication-manager alias="authenticationManager">
<authentication-provider ref="customAuthenticationProvider"/>
</authentication-manager>
<beans:bean id="customAuthenticationProvider" class="com.myCompany.model.security.CustomAuthenticationProvider" >
<beans:property name="databaseId" value="${configuration.databaseId}" />
<beans:property name="applicationId" value="${configuration.applicationId}" />
</beans:bean>
<http auto-config="true" >
<intercept-url pattern="/myApp/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/MyApp.html*" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/gwt/**" access="ROLE_USER"/>
<intercept-url pattern="/**/*.html" access="ROLE_USER"/>
<intercept-url pattern="/css/**" filters="none"/>
<intercept-url pattern="/**" access="ROLE_USER" />
<http-basic />
</http>
<global-method-security secured-annotations="enabled" />
</beans:beans>
【问题讨论】:
-
你的问题是,Spring Security 是基于重定向的。我曾经试图与之抗争,但它需要深入到 SS 内部,所以我放弃了这个想法。在我看来,使用 SS 只过滤频道开销太大,在这种情况下,简单的 HttpFilter 就足够了。
-
@lechlukasz:我不太确定你希望我做什么。你能写一些详细的解释吗?我试图删除所有拦截器,只留下一个:
<intercept-url pattern='/**' access='ROLE_ANONYMOUS,ROLE_CHANGE_PASS,ROLE_VIEWER,ROLE_USER,ROLE_ADMIN'/>,但 SS 即使在身份验证后也将用户视为匿名用户。
标签: java gwt extjs spring-security interceptor