【发布时间】:2010-11-30 12:19:58
【问题描述】:
我一直在使用 Kerberos 扩展的里程碑 2 进行 POC,以实现单点登录。
我的设置快速摘要:
KDC: Windows Server 2003 (SP2)
Web 服务器: Ubuntu 10.04, Tomcat 5.5、Java 1.6.0_22(不在域上)
Spring: Framework 3.0.5、Security 3.0.4、Kerberos Extension 1.0.0 M2
我已将我的配置设置为首先尝试 SPNEGO 身份验证,如果失败则重定向到登录页面。
这是通过设置 SpnegoAuthenticationProcessingFilter 的“failureHandler”属性来完成的。我已经成功测试了这个
在域内外的 Windows 计算机(XP 和 7)上。域外的机器被重定向到
登录页面,然后就可以成功登录了。
这是我的配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<http entry-point-ref="spnegoEntryPoint" auto-config="false">
<intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" />
<intercept-url pattern="/j_spring_security_check*" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/**" access="IS_AUTHENTICATED_FULLY" />
<custom-filter ref="spnegoAuthenticationProcessingFilter" position="BASIC_AUTH_FILTER" />
<form-login login-page="/login.html" default-target-url="/" always-use-default-target="true"/>
</http>
<authentication-manager alias="authenticationManager">
<authentication-provider ref="kerberosServiceAuthenticationProvider" />
<authentication-provider ref="kerberosAuthenticationProvider"/>
</authentication-manager>
<beans:bean id="spnegoEntryPoint"
class="org.springframework.security.extensions.kerberos.web.SpnegoEntryPoint" />
<beans:bean id="spnegoAuthenticationProcessingFilter"
class="org.springframework.security.extensions.kerberos.web.SpnegoAuthenticationProcessingFilter">
<beans:property name="failureHandler">
<beans:bean class="org.springframework.security.web.authentication.ExceptionMappingAuthenticationFailureHandler">
<beans:property name="defaultFailureUrl" value="/login.html" />
<beans:property name="allowSessionCreation" value="true"/>
</beans:bean>
</beans:property>
<beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>
<beans:bean id="kerberosServiceAuthenticationProvider"
class="org.springframework.security.extensions.kerberos.KerberosServiceAuthenticationProvider">
<beans:property name="ticketValidator">
<beans:bean
class="org.springframework.security.extensions.kerberos.SunJaasKerberosTicketValidator">
<beans:property name="servicePrincipal" value="HTTP/mywebserver.corpza.corp.co.za"/>
<beans:property name="keyTabLocation" value="classpath:mywebserver.keytab" />
<beans:property name="debug" value="true"/>
</beans:bean>
</beans:property>
<beans:property name="userDetailsService" ref="dummyUserDetailsService" />
</beans:bean>
<beans:bean id="kerberosAuthenticationProvider" class="org.springframework.security.extensions.kerberos.KerberosAuthenticationProvider">
<beans:property name="kerberosClient">
<beans:bean class="org.springframework.security.extensions.kerberos.SunJaasKerberosClient">
<beans:property name="debug" value="true" />
</beans:bean>
</beans:property>
<beans:property name="userDetailsService" ref="dummyUserDetailsService" />
</beans:bean>
<beans:bean class="org.springframework.security.extensions.kerberos.GlobalSunJaasKerberosConfig">
<beans:property name="debug" value="true" />
<beans:property name="krbConfLocation" value="/etc/krb5.conf" />
</beans:bean>
<beans:bean id="dummyUserDetailsService" class="main.server.DummyUserDetailsService"/>
</beans:beans>
当 Windows 机器在域外时,我的 Web 服务器会使用 "WWW-Authenticate Negotiate" 标头(如往常一样)响应 Windows 机器以 NTLM 标头(“Negotiate TlRM...”)响应,其中 SpnegoAuthenticationProcessingFilter 然后说“协商标头无效...” 并将用户重定向到登录页面。太好了。
问题:
有许多 Mac 和 Linux 机器永久位于需要使用此 Web 应用程序的域之外。
当他们点击网络应用程序(使用 Firefox 3.6)时,我的网络服务器响应预期的 "WWW-Authenticate Negotiate" 标头通知
Web 应用程序是 Kerberized 的客户端,但 Mac 或 Linux 机器根本没有响应。因此 SpnegoAuthenticationProcessingFilter
不会再次输入,因此不会失败,随后不会重定向到登录页面。
问题:
为什么 Mac 和 Linux 机器的响应方式与 Windows 机器不同(简直不敢相信我刚刚问过...)?
我知道当 Mac 和 Linux 机器(通过 kinit)获得票证时,它们能够进行身份验证,但这似乎不是一个好的解决方案 完全没有,因为它需要用户努力提供凭证等,其中票证也会过期。
那么有什么方法可以让这些机器像 Windows 机器一样发回 NTLM 标头? 或者如果有任何其他建议/方法,请告诉我。
顺便说一句。我确实配置了我用来在 Mac 和 Linux 机器上测试的 Firefox("network.negotiate-auth.delegation-uris" 和 "network.negotiate-auth.trusted-uris " 设置为 ".corpza.corp.co.za")。
【问题讨论】:
标签: linux spring-security kerberos single-sign-on