cancel
Showing results for 
Search instead for 
Did you mean: 

Initiator/StartUserId Activiti REST

anjan
Champ in-the-making
Champ in-the-making
Hi, we are using Activiti REST war in our application and we are using custom authentication and it is working perfectly fine.  We can start a process instance…etc.  But when we check the history of a process instance, the "startUserId" value is set to null.

{
            "id": "15001",
            "url": "http://localhost:8080/activiti-rest/service/history/historic-process-instances/15001",
            "businessKey": null,
            "processDefinitionId": "Review:1:2508",
            "processDefinitionUrl": "http://localhost:8080/activiti-rest/service/repository/process-definitions/Review:1:2508",
            "startTime": "2015-04-07T17:16:34.000+05:30",
            "endTime": null,
            "durationInMillis": null,
            "startUserId": null,
            "startActivityId": "start",
            "endActivityId": null,
            "deleteReason": null,
            "superProcessInstanceId": null,
            "variables":
            [
            ],
            "tenantId": ""
        }


Based on my understanding, I need to use the method IdentityService.setAuthenticatedUserId(name) so that the user is set correctly.  Since I am using a custom authentication (as a Filter), how do I get access to IdentityService.  Please let me know, if there is any other way to set this information.
11 REPLIES 11

b_schnarr
Champ in-the-making
Champ in-the-making
No, nothing. All goes with the spring configuration and annotations.

anjan
Champ in-the-making
Champ in-the-making
I am able to resolve the issue.  But I used xml configuration in activiti-custom-context.xml (due to the issues of Autowiring of the beans).

<code>
      <bean id="customHeaderAuthenticationFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
        <property name="principalRequestHeader" value="Custom_User"/>
        <property name="authenticationManager" ref="authenticationManager" />
        <property name="continueFilterChainOnUnsuccessfulAuthentication" value="true" />
        <property name="exceptionIfHeaderMissing" value="false" />
    </bean>
    
    <bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider">
        <property name="preAuthenticatedUserDetailsService">
            <bean id="userDetailsServiceWrapper"  class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
                <property name="userDetailsService" ref="customUserDetailsService"/>
            </bean>
        </property>
    </bean>

    <security:authentication-manager alias="authenticationManager">
        <security:authentication-provider ref="preauthAuthProvider" />
    </security:authentication-manager>  
    
    <bean id="customUserDetailsService" class="com.custom.package.CustomUserDetailsService"></bean>
</code>

Modified SecurityConfiguration to add the following:
<code>
@Autowired
  RequestHeaderAuthenticationFilter customHeaderAuthenticationFilter;

       .addFilterBefore(customHeaderAuthenticationFilter,  BasicAuthenticationFilter.class)
</code>

Also I have removed my custom CustomHeaderAuthenticationFilter as it is not required anymore.

Thanks everyone for al the suggestions.