↓ Skip to main content
A mosaic of pale tiles with five round tokens. Four teal tokens lie in a row. One orange token lies alone under the row.

Authorization: Reusing Maximo's Signature Options

In our skeleton, whether the app opens for a signed-in user is the app’s own decision. It asks the suite for the user’s rights in Maximo Manage and looks for one signature option.

MAS 9.2 series companion app rights

This page follows Logging In Through MAS. The app is our skeleton on our test system, on the MAS 9.2 series. We opened it as three users of our demo data: an administrator, a technician and a planner.

One question to the suite
#

After the sign-in the app holds an access token, and the token names the user. The app then asks the internal API of the suite for the security profile of that user in Maximo Manage. The answer lists what the profile calls resource types, each with its options. Two names in such a list are MAFCONFIG and MTIMPORT, which are applications of Maximo Manage.

For the administrator that list had 673 entries, and the profile answer of our app was 290 KB long. For the technician it had 672, and for the planner 238.

The gate is one look into that list: is this option of this resource type there? The look happens on every request that the gate guards, with a fresh answer each time. A refused user gets a 403 with the text “Forbidden”.

The code
#

This is the whole module:

/**
 * The rights gate: may this user use this app?
 *
 * The suite does not decide that at the Route or at the sign-in. The app does. It asks the
 * internal API of the suite for the user's security profile in Maximo Manage and checks
 * one permission in it, a signature option.
 *
 *   user id from the access token
 *   -> GET /v1/authservice/applications/<APP>/users/<name>/profile  (mutual TLS)
 *   -> allow if permission.resourceTypePermission[<resourceType>][<option>] is present.
 *
 * Set it through the environment (config.authz): use the option of an existing application,
 * point it at an application and option of your own, or set AUTHZ_ENABLED=false to let
 * every signed-in user of the suite in. Maximo Manage still decides about each data call.
 */
import { type Request, type Response, type NextFunction } from "express";
import { jwtDecode } from "jwt-decode";
import { config } from "../config.js";
import { internalApi } from "../lib/internalApi.js";

export const checkUserAccess = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
  if (!config.authz.enabled || !config.isProduction) return next();

  const token = (req.session as any)["x-access-token"] ?? (req.user as any)?.accessToken;
  if (!token) return void res.redirect(`${config.basePath}/login`);

  try {
    const { uniqueSecurityName } = jwtDecode<{ uniqueSecurityName: string }>(token);
    const url = `/v1/authservice/applications/${config.authz.app}/users/${encodeURIComponent(uniqueSecurityName)}/profile`;
    const { data } = await internalApi().get(url);

    const granted = data?.permission?.resourceTypePermission?.[config.authz.resourceType]?.[config.authz.option];
    if (granted !== undefined) return next();

    console.info(`access denied: ${uniqueSecurityName} lacks ${config.authz.resourceType}.${config.authz.option}`);
    return void res.status(403).send("Forbidden");
  } catch (err) {
    // A check that cannot be made is a refusal.
    console.warn("access check failed:", err instanceof Error ? err.message : err);
    return void res.status(403).send("Forbidden");
  }
};

Three settings name what the gate looks for: the application of the suite (AUTHZ_APP, for us Maximo Manage), the resource type (AUTHZ_RESOURCE_TYPE) and the option (AUTHZ_OPTION). A fourth, AUTHZ_ENABLED, switches the gate off.

Four ways to set the gate
#

We changed the settings on the Deployment. Each change starts a new pod.

The gate looks forTechnicianPlanner
MAFCONFIG / READ, the defaultin403
MTIMPORT / IMPORTinin
MTIMPORT / ADMINin403
nothing, the gate is off–in

Read on our test system, MAS 9.2 series. “In” is a 200 for the page and for the three API addresses. A 403 came for the page and for the three API addresses. We did not open the app as the technician with the gate off. The administrator got in at the default gate.

The default borrows an option that exists. Maximo Manage describes the application MAFCONFIG as “Application configuration (Maximo Application Framework Configuration Tool)” and its option READ as “Access to Application configuration”. With this gate, our administrator and our technician got in, and the planner did not. We changed nothing in Maximo Manage for it.

Our own application MTIMPORT has options of its own. MTIMPORT is the application that our product mas-tools.com Data Import installs in Maximo Manage, with options such as IMPORT and ADMIN. With the gate on IMPORT, the planner got in. With the gate on ADMIN, the planner got 403 and the technician got in. The installation guide of that product shows how such an application and its security groups come into Maximo Manage.

With the gate off, every signed-in user is in. That is a choice we can make for an app that only shows what Maximo Manage would show the user anyway.

For a refused user the log of the pod names the user and the option that was missing.

The gate guards the app, and Maximo Manage guards the data
#

Two cut-outs of the same tile, one above the other. Both have the heading “Approved work orders, read as you” and the line “Read from the REST API of Maximo Manage with your own sign-in.” The upper one shows “10 of 1135” and ten work orders at PORTLAND, OTTAWA and CHENGDU. The lower one shows “10 of 354” and ten work orders at BEDFORD.
The same request for the administrator, above, and for the planner

The skeleton has a tile that asks Maximo Manage for approved work orders, with the token of the signed-in user. The administrator and the technician got a total of 1,135. The planner got 354, with the gate on IMPORT and with the gate off.

The app had no rule about work orders. Maximo Manage answered each user with that user’s records. OSLC From a Companion App shows that call.

When the gate cannot ask
#

The module ends with a catch that answers 403, and we tested it. We took away the network policy of the app, so that the pod could not reach the internal API, and asked the app as a signed-in administrator. The answer was 403 after 20 seconds. The log of the pod had one line: the access check had failed on a name lookup. With the policy back, the same request answered 200. We chose to refuse in this case.

What we take from it
#

  • Check one option, and say which. Three settings name it, and the log names it for each refusal.
  • Start with an option that exists, and move to your own. We changed nothing in Maximo Manage for the default.
  • Leave the data to Maximo Manage. Two users got two totals from the same request.
  • Answer 403 when the check fails. Ours did, after 20 seconds without the internal API.

What to read next#

Reaching Manage From Inside the Cluster is about the call behind the gate. OSLC From a Companion App is about the call behind the tile. Anatomy of a MAS Companion App shows the same idea in a released app: one menu for an administrator, a shorter one for a planner.