【问题标题】:Spring Kerberos Extension, SSO and Machines Outside the DomainSpring Kerberos 扩展、SSO 和域外机器
【发布时间】: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


    【解决方案1】:

    您似乎没有设置 network.automatic-ntlm-auth.trusted-uris。你看完了吗?

    https://developer.mozilla.org/en/Integrated_Authentication

    授予

    【讨论】:

      【解决方案2】:

      你走错路了。不要依赖失败的 SPNEGO 过滤器。 Linux 和 Mac 客户端的行为与 Windows 客户端一样。一般设置应如下所示,如果过滤器不实现/不支持,则您发现了一个错误。

      1. 客户端向服务器发送请求
      2. 客户端从服务器接收“401 WWW-Authenticate: Negotiate”(或 Negotiate、Basic、Digest 的任意组合)。
      3. 客户端尝试提供身份验证数据,如果失败,则会显示 401 页面。

      现在您依靠从 Windows 客户端发送的错误/不可处理的数据来呈现表单。您应该直接发送带有 401 的表单,以使所有客户端能够选择适当的登录方法(SPNEGO 或表单,即故障通过)。请记住,form auth 不是像 Negotiate、Digest 或 Basic 这样的 http auth。必须区别对待。

      我们也在使用该过滤器,但我对此并不满意。所以我有实践经验。

      【讨论】:

        猜你喜欢
        • 2013-04-16
        • 1970-01-01
        • 2014-12-24
        • 1970-01-01
        • 1970-01-01
        • 2018-11-11
        • 2021-05-25
        • 2016-12-02
        • 1970-01-01
        相关资源
        最近更新 更多