Search code examples
marklogicmarklogic-8

Rest-Writer and CPF roles


I have a document that I am inserting into the database as role: "rest-writer".. My question is when the CPF is triggered for this document, does the cpf run as "rest-writer" role ? If this is the case is there a way to tell CPF to assume a different role ? or the only way to do is using "amp"


Solution

  • All of the code in your cpf action will be run as the same user that calls the triggering event.

    If you are using functions not part of your user's execute privileges then perhaps:

    Option 1)
    - Add a new role for your user with those privileges - and also add the rest-writer role to keep the existing functionality

    Option 2)
    Amps

    Lastly, to change to a new user, you can do this with xdmp:login() if you add the xdmp:login execute privilege. So yes, you can change users. But this is a very sharp tool. I include this for completeness to your question, but not as a suggested solution in this use-case for sure..