jasig cas服务器返回_cas_stateful_作为用户名与spring

时间:2013-08-23 08:14:56

标签: spring-security cas jasig

我正在尝试从spring安全应用程序连接到cas服务器。当我在CAS中登录时,请求被重定向到我的webapp但在我的UserDetailsS​​ervice中我收到了_cas_stateful_作为用户名,我在webapp中找不到我的用户来加载权限

1 个答案:

答案 0 :(得分:2)

问题是authenticationManager。正如文档所述,您必须使用CasAuthenticationProvider:

<beans:bean id="casAuthenticationProvider"
    class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
    <beans:property name="authenticationUserDetailsService">
        <beans:bean
            class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
            <beans:constructor-arg ref="mongoUserDetailsService" />
        </beans:bean>
    </beans:property>
    <beans:property name="serviceProperties" ref="serviceProperties" />
    <beans:property name="ticketValidator">
        <beans:bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
            <beans:constructor-arg index="0" value="https://localhost:7443/cas" />
        </beans:bean>
    </beans:property>
    <!-- Esta clave es única por aplicación -->
    <beans:property name="key" value="your-provider-auth" />
</beans:bean>

然后,您必须将casAuthenticationProvider设置为authenticationManager:

<authentication-manager alias="authenticationManager">
    <!-- <authentication-provider user-service-ref='mongoUserDetailsService'/>  -->
    <authentication-provider ref="casAuthenticationProvider" />    
</authentication-manager>

如您所见,自定义mongoUserDetailsS​​ervice未分配给authenticationManager而是新的casAuthenticationProvider,然后我们将casAuthenticationProvider设置为authenticationManager