↓ Skip to main content
A paper quilling picture of two large round medallions of coiled paper. The left one is orange, the right one teal. Two paper strips join them: a short straight one between them, and a longer one that curves in an arc below.

Reaching Manage From Inside the Cluster

A companion app runs in the namespace of the suite. From there our app uses two ways to Maximo Manage. Each asks for a credential of its own, and we use each for one kind of question.

MAS 9.2 series companion app inside the cluster

The app is our skeleton on our test system, on the MAS 9.2 series. We sent the with-and-without requests of this page from inside its pod. The totals come from signed-in users of the same app.

Two ways, two credentials
#

d2 diagram d2 diagram

The first way is for what the app itself has to know. The second is for the work orders a user sees.

Internal API of the suiteREST API of Maximo Manage
The credentialthe certificate of the podthe access token of the signed-in user
Who holds itthe podthe app, in the user’s session, from the sign-in
We use it forthe rights of a userthe work orders a user sees
The page about itthis oneOSLC From a Companion App

The certificate of the pod
#

The deploy asks the cluster for a certificate, as Deploying Into a MAS Namespace shows. The internal authority of the suite issues it. The pod mounts it with its key and with the certificate of the authority.

The pod uses this one certificate twice. It serves HTTPS with it, and it shows it when it calls the internal API.

What the internal API answered
#

We asked the internal API from inside the pod, each address once with the certificate and once without:

AddressWith the certificateWithout
its readiness probe200403
the profile of a user id that does not exist500403

We sent no token and no key on these calls. The rights check of the app sends none either: it asks for the profile of the signed-in user with the certificate alone, and got 200. Our administrator’s profile came back to the page as a list of 290 KB.

We read the 500 of the second row as a call that got past the certificate and then found no such user.

The code
#

/**
 * Client for the internal API of the suite (internalapi.<namespace>.svc), with mutual TLS.
 *
 * The pod presents the certificate that it mounts. The internal ClusterIssuer of the suite
 * issued it. On our test system a call with this certificate was answered, and the same
 * call without a certificate got 403.
 *
 * The certificate lives at config.certMountPath (tls.crt, tls.key, ca.crt). It is the same
 * secret that holds the serving certificate for HTTPS.
 */
import fs from "node:fs";
import https from "node:https";
import axios, { type AxiosInstance } from "axios";
import { config, internalApiBase } from "../config.js";

let client: AxiosInstance | null = null;

export function internalApi(): AxiosInstance {
  if (client) return client;
  const p = config.certMountPath;
  const agent = new https.Agent({
    cert: fs.readFileSync(`${p}/tls.crt`),
    key: fs.readFileSync(`${p}/tls.key`),
    ca: fs.readFileSync(`${p}/ca.crt`),
    // Check the certificate of the internal API against the same CA.
    rejectUnauthorized: true,
  });
  client = axios.create({
    baseURL: internalApiBase,
    httpsAgent: agent,
    timeout: 30_000,
    headers: { "Content-Type": "application/json" },
  });
  return client;
}

The client checks the certificate of the internal API against the same authority. So each side shows a certificate to the other.

The first way is for the app, the second for the user
#

The app uses the internal API for one question: what may this user do in Maximo Manage? Authorization: Reusing Maximo’s Signature Options builds the gate of the app on the answer.

The work orders a user sees go the second way, with that user’s own token. Maximo Manage then answers each user with that user’s records. Our administrator and our planner asked for the same work orders and got totals of 1,135 and 354.

That split is a rule we set for our own apps. For the data half, It Works as You shows how mas-tools.com Data Import writes every row as the signed-in user.

The addresses inside the cluster are the ones the pod trusts
#

A pod could also call the suite at its public address. On our test system that failed. From inside the pod, a request to the public address ended with “self signed certificate in certificate chain”.

The service addresses inside the cluster worked. The pod trusts them with the certificate of the internal authority from its mounted secret. Our client for the internal API passes it as ca, and for the other calls the setting NODE_EXTRA_CA_CERTS points at it.

Whose interface this is
#

The REST API of Maximo Manage is a documented interface. The internal API of the suite is the suite’s own. We use one of its addresses, the profile of a user, and we count on having to check it again after each update of the suite.

What we take from it
#

  • Keep the two credentials apart. The certificate belongs to the pod, the token to a user’s session.
  • Ask with the certificate for what the app needs to know. Ours asks for one thing, the rights of a user.
  • Read data with the user’s token. Two users got two totals from one request.
  • Call the services inside the cluster. The public address of the suite was not trusted from our pod.

What to read next#

OSLC From a Companion App is the second way in detail. Logging In Through MAS shows where the token comes from. Anatomy of a MAS Companion App shows the two certificates on one request from the browser.