Spring security RemoteAuthenticationManager:如何配置?
关于这个问题(),我认为我做的都是错的。我尝试使用RESTful服务来提供身份验证,在我应该使用RemoteAuthenticationManager时,该服务来回发送UsernamePasswordAuthenticationToken。(顺便说一句,我已经准备好切换到基本身份验证,因为这太麻烦了。不幸的是,这不是一个选项。) 所以,我重组了 不幸的是,RemoteAuthenticationManager的示例很少 我现在在服务器中有以下bean:Spring security RemoteAuthenticationManager:如何配置?,spring-security,Spring Security,关于这个问题(),我认为我做的都是错的。我尝试使用RESTful服务来提供身份验证,在我应该使用RemoteAuthenticationManager时,该服务来回发送UsernamePasswordAuthenticationToken。(顺便说一句,我已经准备好切换到基本身份验证,因为这太麻烦了。不幸的是,这不是一个选项。) 所以,我重组了 不幸的是,RemoteAuthenticationManager的示例很少 我现在在服务器中有以下bean: <bean id="remoteAu
<bean id="remoteAuthenticationManager" class="org.springframework.security.authentication.rcp.RemoteAuthenticationManagerImpl">
<property name="authenticationManager">
<ref bean="phsAuthenticationManager"/>
</property>
</bean>
<bean id="phsAuthenticationManager" class="com.mystuff.phs.agent.service.AuthenticationManager">
<property name="endpoint" value="${phs.authenticate.endpoint}" />
</bean>
也许我的大脑因为一周来试图配置一个看起来非常简单的界面而崩溃了。请帮忙
编辑以对项目文件进行轻微更改:
一位同事对app-security.xml文件做了一些更改,我已经集成了这里建议的更改。以下是app-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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
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.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true" pattern="/rest/**" entry-point-ref="http403EntryPoint"
authentication-manager-ref="remoteAuthenticationManager">
<intercept-url pattern="/rest/**" access="isAuthenticated()" />
<custom-filter ref="tenantHmacFilter" position="PRE_AUTH_FILTER" />
</http>
<beans:bean id="http403EntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint">
</beans:bean>
<beans:bean id="tenantHmacFilter" class="com.mckesson.phs.agent.filter.TenantHmacFilter">
<beans:property name="authenticationManager" ref="tenantHmacAuthenticationManager" />
</beans:bean>
<beans:bean id="tenantHmacAuthenticationManager" class="com.mckesson.phs.agent.filter.TenantHmacAuthenticationManager">
<beans:property name="tenantId" value="${tenant.id}" />
<beans:property name="tenantKey" value="${tenant.key}" />
</beans:bean>
<beans:bean id="remoteAuthenticationManager" class="org.springframework.security.authentication.rcp.RemoteAuthenticationManagerImpl">
<beans:property name="authenticationManager">
<beans:ref local="authenticationManager" />
</beans:property>
</beans:bean>
<beans:bean id="authenticationManager" class="com.mckesson.phs.agent.service.AuthenticationManagerImpl">
<beans:property name="endpoint" value="${phs.authenticate.endpoint}" />
</beans:bean>
</beans:beans>
您得到的错误是因为类型不匹配。Spring Security authenticationManager的配置如下:
<security:authentication-manager alias="authenticationManager" erase-credentials="true">
...
</security:authentication-manager>
<bean name="/RemoteAuthenticationManager" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service"><ref local="remoteAuthenticationManager"/></property>
<property name="serviceInterface" value="org.springframework.security.authentication.rcp.RemoteAuthenticationManager" />
</bean>
如果您正在寻找HttpInvoker解决方案(两端Spring),则上面的配置如下:
<security:authentication-manager alias="authenticationManager" erase-credentials="true">
...
</security:authentication-manager>
<bean name="/RemoteAuthenticationManager" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service"><ref local="remoteAuthenticationManager"/></property>
<property name="serviceInterface" value="org.springframework.security.authentication.rcp.RemoteAuthenticationManager" />
</bean>
请添加有关您正在尝试执行的操作的更多详细信息。您是否在分布式应用程序中实现了Spring安全性?类似于或?您得到的错误是因为类型不匹配。Spring Security authenticationManager的配置如下:
<security:authentication-manager alias="authenticationManager" erase-credentials="true">
...
</security:authentication-manager>
<bean name="/RemoteAuthenticationManager" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service"><ref local="remoteAuthenticationManager"/></property>
<property name="serviceInterface" value="org.springframework.security.authentication.rcp.RemoteAuthenticationManager" />
</bean>
如果您正在寻找HttpInvoker解决方案(两端Spring),则上面的配置如下:
<security:authentication-manager alias="authenticationManager" erase-credentials="true">
...
</security:authentication-manager>
<bean name="/RemoteAuthenticationManager" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service"><ref local="remoteAuthenticationManager"/></property>
<property name="serviceInterface" value="org.springframework.security.authentication.rcp.RemoteAuthenticationManager" />
</bean>
请添加有关您正在尝试执行的操作的更多详细信息。您是否在分布式应用程序中实现了Spring安全性?类似于或?我有一个服务器(Spring/Hibernate),负责调用web服务或LDAP服务器进行身份验证,以及其他服务,如数据访问。我有一个客户机-服务器应用程序(GWT/Spring/Hibernate),它将使用这些服务。因此,远程身份验证管理器。app-security.xml已更改,我已将其包含在上面。此外,RemoteAuthenticationManagerImpl的完整跟踪堆栈.authenticationManager属性的类型为org.springframework.security.authenticationManager,因此您无法将其连接到com.mckesson.phs.agent.service.AuthenticationManagerImpl,它正在实现RemoteAuthenticationManager。我建议首先在应用程序中配置spring安全性,并使用普通登录表单进行测试,然后实现RemoteAuthentication。如果不需要表单登录,您可以稍后删除(或阻止)表单登录。第一步是配置安全性:使用您需要的身份验证提供程序配置身份验证管理器。我有一个服务器(Spring/Hibernate),负责调用web服务或LDAP服务器进行身份验证,以及其他服务,如数据访问。我有一个客户机-服务器应用程序(GWT/Spring/Hibernate),它将使用这些服务。因此,远程身份验证管理器。app-security.xml已更改,我已将其包含在上面。此外,RemoteAuthenticationManagerImpl的完整跟踪堆栈.authenticationManager属性的类型为org.springframework.security.authenticationManager,因此您无法将其连接到com.mckesson.phs.agent.service.AuthenticationManagerImpl,它正在实现RemoteAuthenticationManager。我建议首先在应用程序中配置spring安全性,并使用普通登录表单进行测试,然后实现RemoteAuthentication。如果不需要表单登录,您可以稍后删除(或阻止)表单登录。第一步是配置安全性:使用您需要的身份验证提供程序配置身份验证管理器。