↓ Skip to main content
An ink and watercolour drawing of a wooden chest with eight small drawers in two rows on a workbench, painted orange and teal. Three drawers carry brass padlocks, four have plain round knobs, and one drawer with a knob is pulled open and empty. A ring with three brass keys lies on the bench in front.

Protecting Script Endpoints

Maximo Automation Scripts - This article is part of a series.
Part 23: This Article
By default, every authenticated user can call every automation script through the REST API. Two settings close that: one for the script route as a whole, and one per script. Both have the same trap, and this article shows how to set them so that they really check.

Article 22 showed how a script answers at /maximo/api/script/<NAME>. This article covers who may call it. We checked IBM’s security pages against the behaviour of Manage in the MAS 9.2 series, and we ran the endpoint examples on our test system.

The open default
#

The two script routes, one for GET and one for POST, come with no application and no option. So the handler checks nothing beyond the login: any user who can log in can call any script by name.

That includes scripts that were never meant as endpoints. A script with launch points can be called too. It then runs without its record: the handler binds no mbo, and on our test system the name did not exist in a script called this way. Such a script stops at its first use of mbo. A script that needs no record runs in full.

So every script that changes data, or reads data that not everyone may see, needs a check.

Protect the route
#

The Object Structures application has an Add/Modify API Route dialog. It lists the two script entries, one for GET and one for POST. Each entry takes an application and an option name. A user then needs that option in that application to call any script through the route.

Three details decide whether the check runs:

  • Both values, or nothing. The check runs only when the entry has the application and the option. With only one of them, nothing is checked.
  • Both entries. GET and POST are separate rows. Set both.
  • The insert site counts. The check uses the user’s insert site. A missing right fails with access#NotAuthorizedForMbo.

Choose an application and a signature option for this, and grant the option to the security groups that may call scripts. The route setting covers calls through /maximo/api/script/<NAME>. Protect sensitive scripts one by one as well.

Protect one script
#

A single script is protected with two variables on the script itself:

VariableBindingValue
authappliteral, IN or INOUTthe application
authsigoptionliteral, IN or INOUTthe signature option

The same trap applies here. The check runs only when both variables exist and both have a value. If one is missing or empty, the check is skipped, and every user can run the script. A user without the option gets access#notauthorized, and the script does not run at all.

The two checks before a script endpoint runs The two checks before a script endpoint runs
The two checks before a script endpoint runs

The two layers work together. The route setting is the floor for every call through the script route. The variables add a specific option for the scripts that matter most.

Write endpoint scripts defensively
#

A check decides who may call. The script itself decides what a call can do. Four habits:

  • Treat input as a value. Build where clauses with SqlFormat and setObject. In article 22, a site value with a quote and or '1'='1 found no rows on our test system, because the quote stayed part of the value.
  • Keep endpoints apart. Give endpoint scripts their own names and their own variables. A script written for a launch point should not double as an endpoint.
  • Fail early and clearly. Check the input first, and stop with service.error. The caller gets an error answer, and nothing has changed yet.
  • Know the off switch. An inactive script is skipped, and the call answers HTTP 200 with an empty body. So deactivating a script stops it at once, but the caller cannot tell. For an emergency, the system property mxe.script.deactivateall switches every script off at once.

Object structure actions and query scripts have their own guards: an option name on the action, and public or role-bound saved queries. Article 24 covers both.

What IBM’s pages leave out
#

IBM’s pages name the route dialog and the two variables. They leave out three things:

  • Both values are required. One missing value on a route entry, or one missing variable on a script, switches that check off.
  • Scripts with launch points are callable too. Neither page says so.
  • The insert site counts in the route check.

Article 33 of this series collects the corrections that matter most.

What comes next
#

Article 24 covers object structure actions and query scripts.

IBM’s own pages are the reference to keep next to this series:

The complete list of corrections, with the evidence for each one, is in our member area. Members get access on request, so get in touch if you want it. If you want help with the scripts in your own Manage, our services page shows how we work.

IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.

Maximo Automation Scripts - This article is part of a series.
Part 23: This Article