Configuring Trusted Mode

This section describes the advantages of trusted mode authentication and how to configure it. Trusted mode is one method allowing end users to log onto the 3DEXPERIENCE platform using the same credentials as those already implemented in a third party authentication system.

Trusted mode federation can be implemented when 3DPassport delegates authentication to a third party system, and as an alternative solution when federated SAML implementation is not possible.

This task shows you how to:

Configuring Trusted Mode manually

  1. Review operating principles and identify key components.

    Trusted mode, unlike other 3DPassport administration mechanisms, is not managed using the admin tools GUI.



    The above operating principle diagram describes how trusted mode federation works when activated:

    • 1. An end user attempts to connect to the 3DEXPERIENCE platform from a client (browser, native app, …).
    • 2. The end user is not authenticated, and the request is redirected to the 3DPassport service.
    • 3. The request goes through an SSO agent component deployed in the TomEE app server. The credentials are checked on the SSO server of the third party identity provider (IdP).
    • 4. The SSO server checks credentials against its user repository.
    • 5. If credentials are successfully checked, the remote user is populated and set in the request and the client is redirected back to the 3DPassport service with a GET or POST request. If credentials are not valid, the agent redirects the end user to the third party identity provider login page.
    • 6. The PreAuth manager checks whether a remote user is present in the request. If the remote user is found, it tries to fetch current user attributes from the repositories (local and external).
    • 6b. If the remote user cannot be found, the request is then processed by the CAS authentication manager (legacy behavior) and callback is performed to the 3DPassport login page if the authenticated session is not valid, or no valid CAS cookie can be found.
    • 7/8. The user service component fetches the user data from the repositories into which the 3DPassport is plugged, for example its own database repository or possibly the customer's own repository (if read only connection is allowed).
    • 9. If the end user is found in a repository, the user session is created and the user is redirected back to the 3DEXPERIENCE platform with a 3DPassport CAS SSO ticket. If the user cannot be found in any repository, the user is redirected back to 3DPassport login page.

    You are now ready to configure trusted mode.

  2. Enable trusted mode.

    You must configure the required resolvers and handler classes that will handle the retrieval of remote users from the request, and activate trusted mode.

    1. Edit the following file:

      <tomee>/webapps/<WEBAPP_NAME>/WEB-INF/spring-configuration/applicationContext-cas.xml

      where <WEBAPP_NAME> is 3dpassport by default.

    2. Set enableTrustedModeFederation in the casServiceAdapterLegacy bean to true:

      <bean id="casServiceAdapterLegacy" class="com.dassault_systemes.dspassport.iamweb.cas.service.impl.CasServiceAdapter" lazy-init="true">

      <property name="enableTrustedModeFederation" value="true"/> 
      …

    3. Modify the preAuthenticationManagers section by uncommenting the following lines:

      ....
      <bean class="org.jasig.cas.adaptors.trusted.authentication.principal.
                   PrincipalBearingCredentialsToPrincipalResolver"/>
      ....
      <bean class="org.jasig.cas.adaptors.trusted.authentication.handler.support.
                   PrincipalBearingCredentialsAuthenticationHandler"/>
      ....
      <property name="preAuthenticationActions">
      	<list>
      		<bean id="principalFromRequestRemoteUser" 
        class="com.dassault_systemes.dspassport.iamweb.cas.authentication.action.impl.
               PreAuthPrincipalFromRequestRemoteUserAction">
                <property name="trustedModeConfiguration" ref="trustedModeConfiguration" />
                <property name="userService" ref="userServiceService" />
                <property name="decodeRemoteUser" value="false" />
                <property name="remoteUserHeaderName" value="" />
      </bean>
      </list>
      </property>
      ....
      

      in the appropriate location as illustrated below:

      ...
      <property name="preAuthenticationManagers">
      	<list>
      		<bean id="authenticationManager"
      		class="org.jasig.cas.authentication.AuthenticationManagerImpl">
      			<property name="credentialsToPrincipalResolvers">
      				<list>
      					<bean class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver"/>
      					<bean class="org.jasig.cas.adaptors.trusted.authentication.
                   principal.PrincipalBearingCredentialsToPrincipalResolver"/>
      				</list>
      			</property>
      			<property name="authenticationHandlers"> 
      				<list> 
      					<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"> 
      			<property name="httpClient" ref="httpClient"/> 
      			<property name="retryTemplate" ref="retryTemplate" /> 
      			<property name="maxAttempts" value="${cas.retry.maxattempts:5}" />
      			<property name="callbackFailedCounter" ref="callbackFailedCounter"></property>
      
      					</bean> 
      					<bean class="org.jasig.cas.adaptors.trusted.authentication.handler.support.PrincipalBearingCredentialsAuthenticationHandler"/> 
      				</list>       
      			</property>
      					</bean>
      				</list>
      			</property>
      			         <property name="preAuthenticationActions"> 
                       <list> 
                                <bean id="principalFromRequestRemoteUser" 
                                 class="com.dassault_systemes.dspassport.iamweb.cas.authentication.action.impl.PreAuthPrincipalFromRequestRemoteUserAction"> 
                                         <property name="trustedModeConfiguration" ref="trustedModeConfiguration" /> 
                                         <property name="userService" ref="userServiceService" /> 
                                         <property name="decodeRemoteUser" value="false" /> 
                                         <property name="remoteUserHeaderName" value="" /> 
                                </bean> 
                       </list> 
               </property>
      
      ...

      “remoteUserHeaderName” property

      By default, the remote user is retrieved from the request by calling the HttpServletRequest.getRemoteUser method in the PreAuthPrincipalFromRequestRemoteUserAction class.

      The remote user name can also be retrieved from a custom header in the request, by setting the remoteUserHeaderName property for the principalFromRequestRemoteUser bean as follows:

      <bean id="principalFromRequestRemoteUser" 
      class="com.dassault_systemes.dspassport.iamweb.cas.authentication.action.impl.
             PreAuthPrincipalFromRequestRemoteUserAction"/>
      <property name="remoteUserHeaderName" value="###CUSTOM_HEADER_NAME###"/>
      </bean>

      decodeRemoteUser" property

      By default, the remote user string is not URL decoded so this property is set to false. If the remote user string contains special characters that needs to be URL encoded up-front, then you need to set this property to true.

  3. Configure logout callback.

    When an end user logs out from the 3DEXPERIENCE platform, the end user is also logged out from 3DPassport and must also be logged out from the third party SSO system. So you need to configure the logout callback URL of the third party SSO system.

    1. Edit the following file:

      <tomee>/webapps/<WEBAPP_NAME>/WEB-INF/spring-configuration/applicationContext-cas.xml

      where <WEBAPP_NAME> is 3dpassport by default.

    2. Add the following line in bold, just before the preAuthenticationManagers section as follows:

      ...
      <property name="forceRedirectUrlAfterLogout" value="${iam.cas.force_redirect_url_after_logout}"/>
         
      <property name="preAuthenticationManagers">
      ...
      Note: The value of the forceRedirectUrlAfterLogout parameter above is a placeholder. The value will be automatically replaced with the placeholder property value set in the dspassport_general.properties file. If you do not want to use a placeholder, you can directly set the URL callback value here, and skip the following steps.

    3. Edit the following file:

      <tomee>/webapps/<WEBAPP_NAME>/WEB-INF/classes/dspassport_general.properties

      where <WEBAPP_NAME> is 3dpassport by default.

    4. Add the following line at the end of the file:

      ...
      iam.cas.force_redirect_url_after_logout=<LOGOUT_CALLBACK_URL>

      and replace <LOGOUT_CALLBACK_URL> by the value of the callback URL of the third party SSO server.

  4. Restart the TomEE web application server to take the configuration into account.

Result: End users can now log onto the 3DEXPERIENCE platform via the logon page of the third party identity provider.

Configuring Trusted mode with JWT

You can use JWT as trusted mode to create and update users automatically in 3DPassport.

  1. Enable the trusted mode as described in Configuring Trusted Mode.
  2. Open the 3DPassport trusted_mode.properties file:

    For external TomEE+ on Linux, go to <externalTomEEInstallPath>/webapps/3DPassport/WEB-INF/classes/trusted_mode.properties

    For external TomEE+ on Windows, go to <externalTomEEInstallPath>\webapps\3DPassport\WEB-INF\classes\trusted_mode.properties

    For embedded TomEE+ on Linux, go to <3DPassportInstallPath>/linux_a64/code/tomee/webapps/3DPassport/WEB-INF/classes/trusted_mode.properties

    For embedded TomEE+ on Windows, go to <3DPassportInstallPath>\win_b64\code\tomee\webapps\3DPassport\WEB-INF\classes\trusted_mode.properties

  3. Edit the trusted_mode.properties file with the following parameters:

    Trusted mode with JWT Example with JWT (General) Example with JWT (Google)
    User can update its profile:

    Allows users to update their profile by using the boolean (true, false) property trusted-mode.user.can-be-updated.

    Default is false.
    trusted-mode.user.can-be-updated=false trusted-mode.user.can-be-updated=false
    User JWT attribute mapping
    • trusted-mode.jwt.user.mapping.username to map username (default is username)
    • trusted-mode.jwt.user.mapping.email to map user email with (default is email)
    • trusted-mode.jwt.user.mapping.firstName to map user first name (default is firstName)
    • trusted-mode.jwt.user.mapping.lastName to map user last name (default is lastName)
    • trusted-mode.jwt.user.mapping.country to map user countr. Default is US.

    If the JWT does not have a trusted-mode.jwt.user.mapping.country attribute, the trusted-mode.jwt.user.mapping.default-country property can be used to set a default value for the country attribute (default is US)

    Note: Use ISO 2 or ISO 3 country codes (ex: FR, FRA, US, USA, etc.).

    The email_verified field is only required if the trusted-mode.jwt.user.email-must-be-verified property is set to true. Default is True.

    • trusted-mode.jwt.user.mapping.username=username
    • trusted-mode.jwt.user.mapping.email=email
    • trusted-mode.jwt.user.mapping.firstName=firstName
    • trusted-mode.jwt.user.mapping.lastName=lastName
    • trusted-mode.jwt.user.mapping.country=country
    • trusted-mode.jwt.user.default-country=FR
    • trusted-mode.jwt.user.mapping.email-verified=email_verified

      trusted-mode.jwt.user.email-must-be-verified=true
    • trusted-mode.jwt.user.mapping.username=sub
    • trusted-mode.jwt.user.mapping.email=email
    • trusted-mode.jwt.user.mapping.firstName=given_name
    • trusted-mode.jwt.user.mapping.lastName=family_name
    • NA
    • trusted-mode.jwt.user.default-country=US
    • trusted-mode.jwt.user.mapping.email-verified=email_verified
    • trusted-mode.jwt.user.email-must-be-verified=true
    JWT claims verification:

    A JWT must always have an iss field. The value of the iss can be specified with the property trusted-mode.jwt.issuers.

    It is possible to specify several issuers, they must be separated by “,”.
    trusted-mode.jwt.issuers=my-issuer.com trusted-mode.jwt.issuers=accounts.google.com,https://accounts.google.com
    JWT signature verification:

    trusted-mode.jwt.allowed-algorithm (default RS256, HS256) to specified several allowed JWT signature algorithm. Algorithms must be separated by the character “,”.

    trusted-mode.jwt.verification-keys to specify several verification keys. Keys must be separated by the character “,”. A key is not alone and must be associated to an algorithm. The form of key is: <algo>:<keyValue>

    trusted-mode.jwt.allowed-algorithms=RS256,HS256

    trusted-mode.jwt.verification-keys=HS256:ahazhraj5464afa,HS256:aqgqgqg645

    trusted-mode.jwt.allowed-algorithms=RS256

    N/A

  4. Restart the TomEE web application server to take the configuration into account.