0
我想配置请求头认证使用春天2.0安全性,我是一个完整的新手在它,所以请忍受我。从doc,他们给出了一个使用siteminder的示例配置文件。春天2.0安全配置
在我的场景中,请求标头中将有一个用户名和用户组,分别使用CC_USER和CC_USER_GROUP的键。所以我调整了文件如下(见下文)。
我知道在外部系统中,用户已经使用某种类型的单点登录进行了身份验证,并且当控件到达我的应用程序时,我们只需检查CC_USER和CC_USER_GROUP的请求标头。
问题1:下面的例子使用“userDetailsService”。这是我需要实现的吗?这是我将检查CC_USER和CC_USER_GROUP的请求标头吗?
问题2:是否有一个完整的例子,我可以下载使用请求头认证的地方?我做了大量的谷歌搜索,但没有找到很多帮助。
问题3:我想对某些虚拟用户进行测试,就像他们在文档中做的一样。我如何将以下内容合并到我的请求标题配置中?
<authentication-provider>
<user-service>
<user name="jimi" password="jimispassword" authorities="ROLE_USER, ROLE_ADMIN" />
<user name="bob" password="bobspassword" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
我修改样本配置文件(基于文档的SiteMinder文件):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<bean id="ssoFilter"
class="org.springframework.security.ui.preauth.header.RequestHeaderPreAuthenticatedProcessingFilter">
<security:custom-filter position="PRE_AUTH_FILTER" />
<property name="principalRequestHeader" value="CC_USER" />
<property name="authenticationManager" ref="authenticationManager" />
</bean>
<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>
<security:authentication-manager
alias="authenticationManager" />
</beans>
@真空 - 感谢您的回答
_RequestHeaderAuthenticationFilter_只是简单地从头中提取用户名,所以如果你还需要建立一个USER_GROUP,你需要创建你自己的RequestHeaderAuthenticationFilter,并直接在过滤器方法中执行此操作。 也许这将有助于:http://teja.tejakantamneni.com/2008/08/spring-security-using-custom.html – vacuum 2012-04-08 22:05:16