【问题标题】:CAS attributes in wsfederation not being forwarded to CAS clientwsfederation 中的 CAS 属性未转发到 CAS 客户端
【发布时间】:2016-07-20 23:35:51
【问题描述】:

我正在为使用 CAS 对 ADFS 进行身份验证的 Tomcat Web 应用程序实施身份验证系统。我用的是unicon的CAS server with ADFS integration

我已经达到了可以看到所需属性到达 CAS 服务器的状态。但是这些属性不会转发给客户端。检查下图:

上图中,认证后属性映射为空。此外,当客户端应用程序验证票证时,属性映射为空。参考下图:

通过身份验证后,属性在日志中可见,但不会加载到属性映射中。

deployerConfigContext.xml 如下。 serviceRegistryDao bean 中的 attributeRepository bean 和允许的 attributes 属性可能是主要关注的领域。

<?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:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:sec="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <bean id="authenticationManager"
        class="org.jasig.cas.authentication.AuthenticationManagerImpl">

        <property name="authenticationMetaDataPopulators">
           <list>
              <bean class="net.unicon.cas.support.wsfederation.authentication.WsFederationAuthenticationMetaDataPopulator" />
           </list>
        </property>
        <property name="credentialsToPrincipalResolvers">
            <list>
            <bean class="net.unicon.cas.support.wsfederation.authentication.principal.WsFederationCredentialsToPrincipalResolver">
                <property name="configuration" ref="wsFedConfig" />
            </bean>
            <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" >
                <property name="attributeRepository" ref="attributeRepository" />
            </bean>
            <bean       class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />
            </list>         
        </property>

        <property name="authenticationHandlers">
            <list>
            <bean class="net.unicon.cas.support.wsfederation.authentication.handler.support.WsFederationAuthenticationHandler" />
            <bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
                p:httpClient-ref="httpClient" />
            </list>
        </property>
    </bean>

    <sec:user-service id="userDetailsService">
        <sec:user name="@@THIS SHOULD BE REPLACED@@" password="notused" authorities="ROLE_ADMIN" />
    </sec:user-service>

    <bean id="attributeRepository"
        class="org.jasig.services.persondir.support.StubPersonAttributeDao">
        <property name="backingMap">
            <map>
                <entry key="emailaddress" value="upn" />
                <!--<entry key="FirstName" value="username" />-->
                <entry key="name" value="LastName" />
                <entry key="costcent" value="costcent" />
                <entry key="title" value="FirstName" />
            </map>
        </property>
    </bean>

    <bean
        id="serviceRegistryDao"
        class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl">
            <property name="registeredServices">
                <list>
                    <bean class="org.jasig.cas.services.RegexRegisteredService">
                        <property name="id" value="0" />
                        <property name="name" value="HTTP and IMAP" />
                        <property name="description" value="Allows HTTP(S) and IMAP(S) protocols" />
                        <property name="serviceId" value="^(https?|imaps?)://.*" />
                        <property name="evaluationOrder" value="10000001" />
                        <property name="allowedAttributes">
                        <list>
            <value>upn</value>
            <value>Department</value>
            <value>costcent</value>
            <value>LastName</value>
            <value>FirstName</value>
            <value>name</value>
            <value>emailaddress</value>
            <value>title</value>
            <value>SAM-Account-Name</value>

                        </list>
                    </property>
                    </bean>

                </list>
            </property>
        </bean>

  <bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" />

  <bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor">
    <property name="monitors">
      <list>
        <bean class="org.jasig.cas.monitor.MemoryMonitor"
            p:freeMemoryWarnThreshold="10" />
        <bean class="org.jasig.cas.monitor.SessionMonitor"
            p:ticketRegistry-ref="ticketRegistry"
            p:serviceTicketCountWarnThreshold="5000"
            p:sessionCountWarnThreshold="100000" />
      </list>
    </property>
  </bean>
</beans>

at CAS服务器的其余部分与unicon的CAS服务器实现here的示例实现相同

我在提到的 bean 中尝试了很多组合。作为 Spring 新手,我无法理解如何在属性映射中加载凭据。请指导我将身份验证期间CAS服务器发送的属性转发给客户端应用程序。

【问题讨论】:

    标签: spring-security single-sign-on cas adfs ws-federation


    【解决方案1】:

    看起来 WsFederationCredentialsToPrincipalResolver 仅从收到的属性集合中提取主体 id,而忽略其他属性。因此,您只能获得配置中定义的身份属性。您暂时可以将该解析器连接到您的属性存储库,并让它从那里使用和检索属性。

    请注意,CAS 4.2 支持并修复了此行为,并内置了对 ADFS 集成的支持。您的另一个选择是扩展 WsFederationCredentialsToPrincipalResolver 并让它处理属性并将它们填充到通过覆盖适当的方法在那里创建的最终主体中。

    【讨论】:

    • 你能解释一下如何将解析器连接到属性存储库并使用它吗?
    • 您最好的指南是浏览 cas 4.2 源代码并适当地重新配置您的扩展。除此之外,基本上你将属性存储库插入到 wsfed 解析器中:&lt;property name="attributeRepository" ref="attributeRepository" /&gt;
    • 关于使用 CAS 4.2 的建议非常有效。作为使用 CAS 4.x 的一部分,需要完成一些额外的配置。努力还是值得的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多