AnsweredAssumed Answered

Can not setAuthenticatedUserId in rest API if there is customization authentication

Question asked by youtianhong on Jul 15, 2015
Latest reply on Jul 21, 2015 by youtianhong
Hello everyone,

As we know, we can set the initiator like below code :

<startEvent id="request" activiti:initiator="initiator" />
The authenticated user must be set with the method BEFORE the process instance is started,
try {
} finally {

The problem is I want to start a new process with variables using the rest api, the command to start this is:

I think it will be successful if we have not a custom authenticator in rest api service side.

The variables like below:

    "variables": [

The following words is jbarrez's feedback in

We've got a unit test for this: ProcessInstanceCollectionResourceTest.testStartProcess().
I ran this here, and it fills the start user just fine (user is set by client.setChallengeResponse(ChallengeScheme.HTTP_BASIC, "kermit", "kermit");
Did you somehowe tweak the rest api or have a custom authenticator?

But the system did not write the 'applyUserId' in field start_user_id of table act_hi_procinst, it always was wrote the word 'system user' that was setted in override 'authenticate' method  by me.
like above mention by jbarrez, I think
the problem maybe was that I did a customization way to override 'authenticate' method.
I also think it will work fine when I remove this customzation, but we don't want to authenticate in rest service side.

So is there any solution for this case ? How can i pass userId in initiator and don't remove authentication  customization.
Any feedback will be greatly appreciated.
Thanks in advance!

To remove authentication in rest api service side, I did a customization,the following is my solution way
1. add customzation config in web.xml

  <!– Restlet adapter –> 
      <!– Application class name –>

2. Create class CustomActivitiRestServicesApplication, the activiti user guide don't mention that override authenticate method,
but for my testing, I need  override this method, otherwise authentication is still need.

public class CustomActivitiRestServicesApplication extends ActivitiRestServicesApplication {
   protected RestResponseFactory restResponseFactory;
          public CustomActivitiRestServicesApplication() {
       restAuthenticator = new RestAuthenticatorImpl();
     public String authenticate(Request request, Response response) {
        if(request.getClientInfo() != null) {
           if(request.getClientInfo().getUser() != null) {
              return request.getClientInfo().getUser().getIdentifier();
        return "system user";

3. Override requestRequiresAuthentication method

public class RestAuthenticatorImpl implements RestAuthenticator {
   public boolean requestRequiresAuthentication(Request request) {
      return false;
   public boolean isRequestAuthorized(Request request) {
      return false;