【问题标题】:Double authentication in GWT / EXT + Spring Security applicationGWT / EXT + Spring Security 应用程序中的双重身份验证
【发布时间】: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:我不太确定你希望我做什么。你能写一些详细的解释吗?我试图删除所有拦截器,只留下一个:&lt;intercept-url pattern='/**' access='ROLE_ANONYMOUS,ROLE_CHANGE_PASS,ROLE_VIEWER,ROLE_USER,ROLE_ADMIN'/&gt;,但 SS 即使在身份验证后也将用户视为匿名用户。

标签: java gwt extjs spring-security interceptor


【解决方案1】:

如果我以正确的方式理解您的问题,您遇到双重身份验证问题,例如Tomcat 身份验证或 Apache Basic AuthSpring 身份验证机制。

在上一个项目中,我遇到了与 Apache Basic AuthSpring 安全机制相关的问题。在发布之前,我的任务是通过简单的Apache Basic Auth“保护”对站点的访问。通过在 Apache 配置中启用此功能,Spring 开始做同样的事情:“Spring Security Application” 一直显示

解决此问题的方法是禁用自动配置

<security:http auto-config="false" ...>
    ...
</security:http>

【讨论】:

    【解决方案2】:

    你的问题不太清楚。您提到了一个 Tomcat 登录屏幕,我假设它是您的 Web 应用程序的第一个屏幕,以允许用户登录。

    如果这是正确的,并且您的登录页面被命名为 login.html,那么您所要做的就是配置拦截器以允许匿名访问该页面-

    <intercept-url pattern="/**/login.*" 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" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      • 2011-09-30
      • 2012-02-18
      • 2022-01-15
      • 2014-02-26
      • 2012-03-07
      • 2013-04-25
      相关资源
      最近更新 更多