Malachi.Console.Api (malachi v0.22.7)

View Source

The console's versioned API under /api/v1, matched by Malachi.Console.Router before the single page application fallback, which would otherwise answer any extensionless path with index.html.

Every route is authorized by Malachi.Console.Access from its table, and every error is an application/problem+json body from Malachi.HTTP.Problem: a path no route serves is a 404 and a method a route does not take is a 405 with Allow, both answered before any credential is read, so probing for routes costs no rate limit budget and learns nothing about sessions.

GET /api/v1/me

Who the console is talking to, so the shell renders by role instead of discovering a 403 after a click (section 6.1 of docs/design/operator-interfaces.md, row 2 of table 10.3). It requires a valid session and no role: an account with only wire permissions is answered with role: null and no capabilities, which is what lets the shell say why it shows nothing.

{
  "username": "alice",
  "authenticated": true,
  "role": "viewer",
  "capabilities": ["read_cluster"],
  "permissions": ["produce"],
  "locale": "en_US",
  "cluster": {"name": "prod-eu", "color": "#A1B2C3", "icon": "globe"}
}

authenticated is false, username null and role "admin" while authentication is disabled (Malachi.Console.Access.anonymous/0). locale is the node's (Malachi.I18n.locale/0); cluster comes from MALACHI_CLUSTER_DISPLAY_NAME, MALACHI_CLUSTER_COLOR and MALACHI_CLUSTER_ICON (Malachi.Config.cluster_identity/3), each null when unset.

Summary

Functions

Whether conn is addressed to this API, so the router hands it here.

Answers an /api/v1 request.

Functions

api_request?(conn)

@spec api_request?(Plug.Conn.t()) :: boolean()

Whether conn is addressed to this API, so the router hands it here.

call(conn)

@spec call(Plug.Conn.t()) :: Plug.Conn.t()

Answers an /api/v1 request.