Running one agent as user or anonymous
An interesting question landed on my desk: " In a web application you use extensive agents to prepare or render content. When the user is authenticated you want that agent to run in the user's context. For anonymous users you want the agent to run in the agent signers security context, so you don't need to expose your resources to anonymous browsing. How to do that?"
- Write all your business code in functions in a script library. Have one function as entry point. It is a matter of taste to use the documentContext as parameter or to retrieve that inside the function.
- Write two agents that both call that function: "agAnonymous" and "agUser". Configure the first one to run with the signer access, the second one to run as web user.
- In your WebQuer[Open|Close] use this formula:
agentToRun := @if(@UserName = "Anonymous";"agAnonymous";"agUser");