cancel
Showing results for 
Search instead for 
Did you mean: 

Wrapping functionality to run as system user...

rberg
Champ in-the-making
Champ in-the-making
Hello,

I was wondering if there is a way to wrap the execution of certain code so that it is run as the system user or a user with more priveledges.

I am running into an issue where I would like to perform some checks, but the currently authenticated user does not have the priveledges to do so.

Specifically, I have created notification functionality that allows you to alert other users to a document. But, I would like to filter the list of users that can be selected based on whether or not they have read priviledges on the document that is being alerted.  Every approach I have tried I have been thwarted.

You help is greatly appreciated.
-Ryan
2 REPLIES 2

andy
Champ on-the-rise
Champ on-the-rise
Hi

There are two ways to do this

1) Yes, you can run as the system user if you get hold of the AuthenticationComponent. You need to keep the current user and restore the current user in a finally block.

2) Use a non-service bean (which will not have security checks)
This will maintain auditing etc against the current user.
For example there are two node service beans "nodeService" and "NodeService". The first is the internal bean, the second is the public service: the first bean wrapped with security and transactional proxies.

I would suggest selected use of the second approach.

Regards

Andy

risenhoover
Champ in-the-making
Champ in-the-making
This is some great information and it's helping me a bit, but I'm a little confused as to how to configure my system to pick up the non-proxied nodeService.  I am writing a Java-backed action that needs to run as the system user.  I don't know where to specify the different nodeService in the configuration files.

On the other hand – I'd like to explore using the AuthenticationComponent as a solution, but I don't know how to get a reference to that from within an action.

Any thoughts?