我正在尝试将spring security与我现有的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>
并且在http块下应该提到自定义过滤器,我想将两个自定义过滤器都称为“FORM_LOGIN_FILTER”。我想提一下如下
<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>
但是当我试图运行该项目时,它给出了以下错误
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
当我只给一个带有一个自定义过滤器的http块时,它工作正常。但是只有当我给出多个http块(这是正确的,因为我们不能给出具有相同模式的多个http块)或多个具有相同位置“FORM_LOGIN_FILTER”的自定义过滤器时,我才会收到错误。请提供有关如何使用具有相同位置“FORM_LOGIN_FILTER”和相同http模式的多个过滤器的任何建议。