enhancement
major
major
major
#29858
Privileged TL-Script functions: authorize a configured script as a whole by a command group on a computed security object
Extension of the model based security (#29088, #29782): a configured TL-Script function can be authorized as a whole instead of checking every step of its implementation.
Motivation
In a secured evaluation every step of a script is checked against the user's rights (attribute Read / Write, Create, Delete, Discover). A complex business operation (e.g. "approve a ticket": set the state, write an audit entry, update the project) would therefore require the user to hold every single low-level right involved. Often the business rule is a different one: a user holding the operation Approve on the project of the ticket may perform the whole operation.
Design (summary)
- New script type privileged-script (PrivilegedScript extends ConfiguredScript) in the configured TL-Script functions (ConfiguredTLScriptFunctions). The plain configured-script stays unchanged.
- Mandatory security-object: an expression over the script parameters computing the object the check is made on. Evaluated unsecured (the arguments are already restricted to discoverable objects).
- Mandatory command-group: the operation the user must hold on the security object, resolved like the operation of a grant.
- Optional on-denied: an expression over the script parameters, evaluated secured, whose result becomes the result of the function when the user lacks the right (e.g. null, or throw(...) with a custom message). Without it, a denied call fails with a TopLogicException.
- Call from a secured evaluation: compute the security object, check isAllowed(currentUser, object, commandGroup), on success run the implementation unsecured and filter the result for Discover. A security object that is no single persistent object (null, a collection, a transient object, an object created in the current transaction, a create overlay) denies the call; an edit overlay of a form is checked as the object it edits. Call from an unsecured evaluation: no check, unchanged behaviour. Nested privileged scripts inside the unsecured implementation are not checked again.
- New TL-Script function canCall(call) reporting whether the current user may make a call of a configured function without making it (for the executability of buttons), e.g. canCall(approveMilestone($m)): only the arguments of the call are evaluated; for a privileged script the security object and the command group are checked, a plain configured function may always be called; an argument that is no call of a configured function is a compile error.
The specification is the developer article com.top_logic/src/main/java/META-INF/tl-docs/access-privileged-scripts.md. Examples: approving a milestone in tl-demo-react, promoting the responsible person of a DemoTypes A to a DemoTypes administrator in tl-demo (scripted test TestPrivilegedScripts).
Out of scope
- Privileged Java functions (TLScriptFunctions, MethodBuilder).
- A generic privileged(...) wrapper inside TL-Script.
- Extending the security coverage check to command groups used only by scripts.