【问题标题】:jasig cas server returning _cas_stateful_ as username with springjasig cas服务器返回_cas_stateful_作为spring的用户名
【发布时间】:2013-08-23 08:14:55
【问题描述】:

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

【问题讨论】:

    标签: spring-security cas jasig


    【解决方案1】:

    问题出在 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-27
      • 2014-06-01
      • 2014-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多