Wiki Reference
mirexa-cli token
The offline token issuer — keygen, issue and inspect, every flag, the key-file rules and what a token commits you to.
mirexa-cli token makes the session tokens a Mirexa node checks when authentication is on. It is
entirely offline: no daemon, no network, no state beyond the key files you point it at. You
generate an Ed25519 signing keypair once, put the public half in each node's configuration,
and mint short-lived tokens with the private half. A node verifies a token's signature
against its trusted keys, so it never needs to contact anything to accept one. For the whole
setup, see Authentication and tokens.
Usage
mirexa-cli token keygen -name ops -dir ./keys
mirexa-cli token issue -key ./keys/ops.key -perms READ_CANDLES,WRITE_CANDLES -validity 1h > token
mirexa-cli token inspect -pub ./keys/ops.pub "$(cat token)"
| Command | What it does |
|---|---|
keygen |
Generate an issuing keypair. |
issue |
Mint a signed token. |
inspect |
Decode a token, and optionally verify its signature. |
mirexa-cli token, mirexa-cli token help, -h or --help print the command list; with no
arguments that is an error (exit 1), with a help argument it exits 0.
keygen
| Flag | Default | Meaning |
|---|---|---|
- |
required | The issuer name. It is also the key files' name stem and the name you give the key in the node's configuration. No path separators. |
- |
. |
Directory to write the keypair into. |
Writes <dir>/<name>.key (the private key, mode 0600) and <dir>/<name>.pub (the public
key, 0644). Each file is the key in base64 on one line. keygen refuses to overwrite an
existing private key: replacing it would make every token issued from it stop verifying, so
move the old file aside first. The public file is overwritten freely.[1]
It prints, on standard output, the two paths and the configuration snippet to paste into each node:
security:
auth:
enabled: true
trusted_keys:
- name: ops
public_key: "<base64 public key>"
public_key is the key itself, inline, not a path to the .pub file.
issue
| Flag | Default | Meaning |
|---|---|---|
- |
required | The private key file. |
- |
required | Comma-separated permission names (case-insensitive): READ_, READ_, WRITE_, WRITE_, ADMIN_, LIST_, ADMIN_. An unknown name is an error, never skipped; a token granting nothing is refused. |
- |
0 | Tenant id, 0–65535. Signed into the token; at this version the node records it for the session and refuses a renewal naming another tenant, and nothing else reads it. |
- |
30m | How long the token is valid. Must be positive and at most 1h (MaxTokenValidity); the node refuses a token that claims longer. |
The token goes to standard output alone, so issue > token yields a usable file; a
summary goes to standard error:
issued: tenant=0 perms=READ_CANDLES expires=2026-10-30T09:53:29Z (in 5m0s)
The token is the base64 of the handshake's INIT payload — tenant, expiry, permission bitmap
and Ed25519 signature — so a client presents it verbatim, and nothing converts it on the
way.[2] What each permission allows is on Permissions. The node also
caps every grant at its own security.max_permissions, so a token may get less than it asks
for.
inspect
| Flag | Default | Meaning |
|---|---|---|
- |
none | A public key file to verify the signature against. |
Takes exactly one token argument, after the flags (inspect -pub ops.pub TOKEN; a flag
after the token is read as a second argument and refused). It prints:
tenant: 0
permissions: READ_CANDLES
expires: 2026-10-30T09:53:29Z
status: valid for another 4m59s
signature: valid, signed by ./keys/ops.pub
Without -pub the last line is signature: NOT CHECKED (pass -pub to verify): decoding is
not validation. A token that does not verify against -pub prints INVALID and exits 1. An
expired token prints EXPIRED <how long> ago and still exits 0.
Key-file permissions
A private key mints tokens for any tenant and any permission, so issue refuses to load one
whose mode grants any bit to group or others (mode & 0o077 non-zero):[1:1]
mirexa-cli token: auth: malformed key: private key file is readable by group or others: ./keys/ops.key has mode 0644, want 0600 or stricter (chmod 600 ./keys/ops.key)
A node holds only public keys, which are not secret and carry no such check.
mirexa-cli certs and the node apply the same rule to node certificate keys.
What a token commits you to
- A token cannot be withdrawn. It is valid until it expires, which is why the default is 30 minutes and the ceiling an hour. A leaked token is contained only by its expiry.
- A leaked signing key is contained by rotating it: generate a new keypair, add its public
key to
trusted_keysbeside the old one, reissue, then remove the old entry. The configuration takes a list so that this sequence has no window in which nothing verifies. Until the old entry is removed, the old key still mints valid tokens. - On a cluster, an issuer key can also be revoked through the control plane: from the moment a node applies the revocation, it refuses that key's handshakes and renewals and ends its sessions at their next frame. See Control-plane gRPC API and Authentication and tokens. That revokes a key, not one token.
- A long-running client should read its token from a file the operator rewrites (the Go SDK's
TokenSource,-token-fileon the command-line tools,token_filein Python); it then renews over its open connection before the token expires.
keygen prints a one-line reminder of the first two points.
Exit status
0 on success; 1 on any error, printed as mirexa-cli token: <reason> — including -h on a
sub-command (the standard library's "flag: help requested").
References
Source
- /cmd/cli/token.go — the three commands and
blastRadius. - /internal/auth/keyfile.go — key-file format, the 0600 rule, refusal to overwrite.
- /internal/auth/keyring.go — signing and verification against trusted keys.
- /internal/wire/handshake.go —
EncodeToken,ParseToken, the permission names,MaxTokenValidity.
Tests
TestKeygenIssueInspect_RoundTrip,TestKeygen_PrivateKeyIsOwnerOnly,TestKeygen_RefusesToOverwrite,TestIssue_RefusesAGroupReadableKey,TestIssue_Refuses,TestIssue_AtTheCeilingIsAccepted,TestIssue_MintsAdminStream,TestIssue_TokenIsAloneOnStdout,TestInspect_SaysWhenItHasNotChecked,TestInspect_RejectsAForeignToken,TestInspect_ReportsExpiry,TestRun_UnknownSubcommand— /cmd/cli/token_test.go.TestAuth_SDKPresentsACLIIssuedToken— /tests/auth_end_to_end_test.go: a token from this tool accepted by a real node through the SDK.
Further reading
- Authentication and tokens, Permissions
- mirexa-cli certs — the matching tool for node certificates.
External
- RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA), S. Josefsson and I. Liusvaara — https://www.rfc-editor.org/rfc/rfc8032
WritePrivateKeyFile,WritePublicKeyFile,LoadPrivateKeyFileandPrivateKeyFileModein /internal/auth/keyfile.go. ↩︎ ↩︎EncodeTokenin /internal/wire/handshake.go;runIssuein /cmd/cli/token.go. ↩︎