Sunday, April 10, 2016

CAS attributes in wsfederation not being forwarded to CAS client

Leave a Comment

I am implementing an authentication system for a Tomcat web application that gets authenticated against ADFS using CAS. I am using unicon's CAS server with ADFS integration.

I have reached to the state where I can see that the required attributes reach the CAS server. But these attributes are not getting forwarded to the client. check the figure below: enter image description here

In the above image, the attribute map is empty after authentication. Also, when the client application validates the ticket, the attribute map is empty. Ref picture below:

enter image description here

After getting authenticated, the attributes are visible in the logs, but they are not being loaded into attribute Map.

The deployerConfigContext.xml is as follows. The attributeRepository bean and allowed attributes property in serviceRegistryDao bean are the probably the main focus areas.

<?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> 

The rest of the at CAS server is same as in the sample implementation of unicon's CAS-server implementation here

I've tried a lot of combinations in the mentioned beans. Being new to Spring I could not understand how to load the credentials in the attributeMap. Kindly guide me in forwarding the attributes sent by CAS server during authentication to the client application.

1 Answers

Answers 1

It looks like the WsFederationCredentialsToPrincipalResolver only extracts the principal id from the collection of attributes received, and ignores other attributes. So you only get the identity attribute defined in your configuration. You could for the time being, connect that resolver to your attribute repository and have it consume and retrieve attributes from there.

Note that CAS 4.2 supports and fixes this behavior and has built-in support for the ADFS integration. Your other option would be to extend WsFederationCredentialsToPrincipalResolver and have it process attributes and stuff them into the final principal created there by overriding the appropriate method.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment