【问题标题】:Using Tomcat NTLM with Spring Security将 Tomcat NTLM 与 Spring Security 一起使用
【发布时间】:2011-04-16 19:08:53
【问题描述】:

我将 Spring Security 2 与 Spring MVC 一起使用。我将使用的 tomcat 容器已经支持 NTLM,并且在将用户名转发到请求的标头中之前,将只向经过身份验证的用户提供访问权限。

我尝试编写一个自定义的 AutenticationEntryPoint,因为请求标头已经包含用户 ID,因此不需要表单/ http-basic 登录。但到目前为止,我还没有找到实现这一目标的方法。

任何想法和建议都将受到高度赞赏。

谢谢。

【问题讨论】:

    标签: authentication tomcat ntlm spring-security


    【解决方案1】:

    看看Waffle。也许 Waffle 本身不是您想要的,但它有一个弹簧安全过滤器实现,它位于您想要实现的目标的接收端。

    【讨论】:

    • 我实际上发现 Spring security 对预认证安全性具有原生支持。特别是,我查看了 org.springframework.security.ui.preauth.Abs​​tractPreAuthenticatedProcessingFilter,它带有许多实现,其中 RequestHeaderPreAuthenticatedProcessingFilter 似乎最有用。
    【解决方案2】:

    我实际上发现 Spring 安全性具有对预身份验证安全性的原生支持。特别是,我查看了 org.springframework.security.ui.preauth.Abs​​tractPreAuthenticatedProcessingFilter,它带有许多实现,其中 RequestHeaderPreAuthenticatedProcessingFilter 似乎是最有用的。或者,也可以通过扩展 AbstractPreAuthenticatedProcessingFilter 来编写自定义过滤器。完成后,您还需要在应用程序上下文中定义一个自定义入口点,以及 Spring Security 所需的其他依赖项。抱歉,我很着急,没有时间正确格式化它。希望这会有所帮助。

    <bean id="customEntryPoint"
        class="org.springframework.security.ui.preauth.PreAuthenticatedProcessingFilterEntryPoint" />
    

    还有这个

    <bean id="preauthAuthProvider"
            class="org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationProvider">
        <security:custom-authentication-provider />
        <property name="preAuthenticatedUserDetailsService">
            <bean id="userDetailsServiceWrapper"
                    class="org.springframework.security.userdetails.UserDetailsByNameServiceWrapper">
                <property name="userDetailsService" ref="userDetailsService" />
            </bean>
        </property>
    </bean>
    

    还有这个

    <bean id="userDetailsService" class="yourimplementation.CustomUserDetailsService" />
    

    还有这个

    <security:http auto-config="false"
            access-decision-manager-ref="accessDecisionManager"
            entry-point-ref="customEntryPoint">
        <security:intercept-url pattern="/*" access="permitAll" />
    </security:http>
    <security:authentication-manager alias="authenticationManager" />
    

    【讨论】:

      猜你喜欢
      • 2021-09-03
      • 2011-01-15
      • 2011-01-23
      • 2014-12-20
      • 2014-12-11
      • 2015-01-25
      • 2012-10-30
      • 1970-01-01
      • 2018-08-07
      相关资源
      最近更新 更多