Spring安全多个登录筛选器错误

Spring安全多个登录筛选器错误,spring,spring-security,Spring,Spring Security,我正在尝试将spring安全性与我现有的spring项目集成。我的要求是一个用户应该能够使用oAuth登录,另一个用户应该能够使用LDAP登录。为此,我包括了两个自定义过滤器。这是我的密码 <bean:bean xmlns="http://www.springframework.org/schema/beans" id="tenant2FormLoginFilter" class="com.packtpub.springsecurity.web.au

我正在尝试将spring安全性与我现有的spring项目集成。我的要求是一个用户应该能够使用oAuth登录,另一个用户应该能够使用LDAP登录。为此,我包括了两个自定义过滤器。这是我的密码

    <bean:bean xmlns="http://www.springframework.org/schema/beans"
        id="tenant2FormLoginFilter"
        class="com.packtpub.springsecurity.web.authentication.TenantUsernamePasswordAuthenticationFilter">
    <property name="filterProcessesUrl" value="/login2"/>
    <property name="authenticationManager" ref="authenticationManager"/>
    <property name="usernameParameter" value="un"/>
    <property name="passwordParameter" value="pw"/>
    <property name="authenticationSuccessHandler">
        <bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
            <property name="defaultTargetUrl" value="/default"/>
        </bean>
    </property>
    <property name="authenticationFailureHandler">
        <bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
            <property name="defaultFailureUrl" value="/login/form?error"/>
        </bean>
    </property>
</bean:bean>

    <bean:bean xmlns="http://www.springframework.org/schema/beans"
        id="tenant2FormLoginFilter"
        class="com.packtpub.springsecurity.web.authentication.TenantUsernamePasswordAuthenticationFilter">
    <property name="filterProcessesUrl" value="/login2"/>
    <property name="authenticationManager" ref="authenticationManager"/>
    <property name="usernameParameter" value="un"/>
    <property name="passwordParameter" value="pw"/>
    <property name="authenticationSuccessHandler">
        <bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
            <property name="defaultTargetUrl" value="/default"/>
        </bean>
    </property>
    <property name="authenticationFailureHandler">
        <bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
            <property name="defaultFailureUrl" value="/login/form?error"/>
        </bean>
    </property>
</bean:bean>

由于自定义过滤器应该在http块下提及,我想将这两个自定义过滤器都称为“FORM\u LOGIN\u FILTER”。我想在下面提到

    <bean:bean xmlns="http://www.springframework.org/schema/beans"
        id="tenant2FormLoginFilter"
        class="com.packtpub.springsecurity.web.authentication.TenantUsernamePasswordAuthenticationFilter">
    <property name="filterProcessesUrl" value="/login2"/>
    <property name="authenticationManager" ref="authenticationManager"/>
    <property name="usernameParameter" value="un"/>
    <property name="passwordParameter" value="pw"/>
    <property name="authenticationSuccessHandler">
        <bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
            <property name="defaultTargetUrl" value="/default"/>
        </bean>
    </property>
    <property name="authenticationFailureHandler">
        <bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
            <property name="defaultFailureUrl" value="/login/form?error"/>
        </bean>
    </property>
</bean:bean>
<http use-expressions="true"
        entry-point-ref="loginEntryPoint">
    <custom-filter ref="tenant1FormLoginFilter"
            position="FORM_LOGIN_FILTER"/>
    <logout logout-url="/logout"
            logout-success-url="/login/form?logout"/>
</http>

<http use-expressions="true"
        entry-point-ref="loginEntryPoint">

    <custom-filter ref="tenant2FormLoginFilter"
            position="FORM_LOGIN_FILTER"/>
    <logout logout-url="/logout"
            logout-success-url="/login/form?logout"/>
</http> 

但当我试图运行该项目时,它给出了以下错误

    <bean:bean xmlns="http://www.springframework.org/schema/beans"
        id="tenant2FormLoginFilter"
        class="com.packtpub.springsecurity.web.authentication.TenantUsernamePasswordAuthenticationFilter">
    <property name="filterProcessesUrl" value="/login2"/>
    <property name="authenticationManager" ref="authenticationManager"/>
    <property name="usernameParameter" value="un"/>
    <property name="passwordParameter" value="pw"/>
    <property name="authenticationSuccessHandler">
        <bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
            <property name="defaultTargetUrl" value="/default"/>
        </bean>
    </property>
    <property name="authenticationFailureHandler">
        <bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
            <property name="defaultFailureUrl" value="/login/form?error"/>
        </bean>
    </property>
</bean:bean>
    A universal match pattern ('/**') is defined  before other patterns in the 
    filter chain, causing them to be ignored. Please check the ordering in your     
    <security:http>namespace or FilterChainProxy bean configuration
通用匹配模式('/**')在中的其他模式之前定义
过滤链,导致忽略它们。请在您的邮箱中查看订单
命名空间或FilterChainProxy bean配置

当我只给出一个带有一个自定义过滤器的http块时,它工作得很好。但只有当我给出多个http块(这是正确的,因为我们不能给出具有相同模式的多个http块)或具有相同位置的多个自定义筛选器“FORM\u LOGIN\u FILTER”时,我才会出错。请给出如何使用具有相同位置“FORM\u LOGIN\u FILTER”和相同http模式的多个筛选器的建议

不能有两个具有相同请求匹配器的
元素(您的两个元素都具有默认匹配器)。您说过“一个用户可以做X”,那么您将如何决定使用哪个身份验证通道?也许在请求中有一个签名(比如一个不同的路径)?可能是ya的副本我理解,但我想对同一http块使用两个具有相同提供程序“FORM_LOGIN_FILTER”的自定义筛选器,这是我无法做到的。请对此给出任何建议。@Raghavendra-这仍然是一个问题吗?@avijendr是的。。我的实际问题是(请参阅此链接)。为了解决这个问题,我尝试了不同的方法。我仍然无法解决这个问题
    <bean:bean xmlns="http://www.springframework.org/schema/beans"
        id="tenant2FormLoginFilter"
        class="com.packtpub.springsecurity.web.authentication.TenantUsernamePasswordAuthenticationFilter">
    <property name="filterProcessesUrl" value="/login2"/>
    <property name="authenticationManager" ref="authenticationManager"/>
    <property name="usernameParameter" value="un"/>
    <property name="passwordParameter" value="pw"/>
    <property name="authenticationSuccessHandler">
        <bean class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
            <property name="defaultTargetUrl" value="/default"/>
        </bean>
    </property>
    <property name="authenticationFailureHandler">
        <bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
            <property name="defaultFailureUrl" value="/login/form?error"/>
        </bean>
    </property>
</bean:bean>