Wiki Operations
Authentication and tokens
How Mirexa authenticates clients with offline-signed Ed25519 tokens — issuing them, trusting keys, the grant ceiling, expiry, renewal, key revocation in a cluster, and control-plane admin authentication.
Mirexa authenticates a client by a session token: a short claim — tenant, expiry and a
permission bitmap — signed with an Ed25519 key. Tokens are minted offline by
mirexa-cli token; a node holds only the issuers' public keys and verifies each token
itself, with no token service and no network call. Authentication is on by default
(since 2026-10-31): a single node with no keys configured makes its own issuer and admin
token on first start, so it serves nothing unauthenticated and still needs no setup.
The model
sequenceDiagram participant Op as Operator (holds private key) participant C as Client participant N as Node (holds public keys) Op->>Op: mirexa-cli token issue -perms ... -validity 30m Op->>C: token (112 characters) C->>N: INIT frame = the token N->>N: signature, revoked key, expiry, validity window, defined bits N->>N: grant = token permissions ∩ security.max_permissions N-->>C: INIT_ACK with the grant
- A token is the handshake. Its 84 bytes (tenant 2, reserved 2, expiry 8, permissions 8, signature 64) are the INIT frame's payload; the 112-character string is their base64. The client sends it verbatim.
- The signature covers everything else, under a domain-separation prefix
(
mirexa-cst-v1), so no field can be edited without the key. - The node's grant can only be narrower than the token. It is the token's permissions
intersected with
security.max_permissions, and it is returned to the client in INIT_ACK so the client knows what it actually holds. - Permissions are checked per request. A frame the session's grant does not cover is
refused with
Unauthorized(0x0003). See permissions for each bit and the frames it guards.
What is checked, in order
| Check | Applies with auth off? | Refusal message (to the client) |
|---|---|---|
| Not yet expired | yes | session token has expired; issue a fresh one |
| Expiry no more than one hour ahead | yes | session token expires further out than 1h0m0s; it cannot have been legitimately issued |
| Signature from a trusted key | no (anything is accepted) | session token signature is not from a trusted issuer; check security. |
| Signing key not revoked by the cluster | cluster only | session token is signed by a key this cluster has revoked; issue one under a trusted key |
| No undefined permission bits | yes | session token requests a permission this server does not define |
A refused handshake gets an ERROR frame with code Unauthorized and one of these
messages before the connection closes, so a client learns why. The outcome is counted in
mirexa_init_handshakes_total{result} (expired, validity_exceeded,
invalid_signature, undefined_permission, revoked, timeout, …).[1]
A single node issues its own tokens
security.auth.enabled is true by default. A node with it on and
security.auth.trusted_keys empty, not clustered, provisions its own issuer at
startup:[2]
| File | Mode | What it is |
|---|---|---|
<data_ |
0700 | the directory |
<data_ |
0600 | an Ed25519 private key, generated on first start, in the format mirexa- writes |
<data_ |
its public half, trusted under the name local |
|
<data_ |
0600 | a token carrying every permission (READ_, READ_, WRITE_, WRITE_, ADMIN_, LIST_, ADMIN_), valid for one hour, the most a node accepts |
The startup log says auth: no trusted_keys configured, so this node issues its own tokens,
with the two paths as admin_token and issuer_key. While the node runs it re-mints the
admin token every 20 minutes, so the file always holds one with at least 40 minutes left.
The key is reused on every later start, so a token minted before a restart still verifies
after it.
Point a client at the file rather than copying the token out of it: mirexa-cli with
-token-file <data_dir>/auth/admin.token, the Go SDK with an Options.TokenSource that
reads it, the Python SDK with token_file=. Each re-reads the file on every reconnect, and
the two SDKs also renew over the open connection at two-thirds of a token's life, so a
long-running client keeps working (Renewal).
The admin token can do anything. Mint narrower ones from the same key for everything else:
mirexa-cli token issue -key <data_dir>/auth/issuer.key -perms READ_CANDLES -validity 30m
Configuring any trusted_keys turns this off: nothing is generated, and a key generated
earlier is no longer trusted. A cluster cannot use it — each node would generate a
different issuer, and a token from one would be refused by the node it is redirected to —
so a node with cluster.enabled: true, auth on and no trusted keys is refused at config
load; list the same public key on every node.[3]
Turning it off
With security.auth.enabled: false, the node accepts any token, including the unsigned
request a client sends when it has no token at all. The permission bitmap is then whatever
the client asks for: authorization is effectively decorative. A tokenless SDK client asks
for read and write on candles and ticks, ADMIN_STREAM and LIST_STREAMS
(permissions). A node with auth on refuses
every tokenless client. Every startup logs the posture ("auth":false or the trusted issuer
names), so a node accepting unsigned tokens says so.
One control works either way: security.max_permissions clamps every grant, with
auth on or off. Setting it to [READ_CANDLES, READ_TICKS] makes a node read-only to every
client, whatever its token says.[4]
Setting up
The node's own issuer (above) is enough for one node. Make a keypair of your own to keep the private key off the node, or for a cluster, whose nodes must all trust the same key.
1. Make a signing keypair
mirexa-cli token keygen -name ops -dir ./keys
The directory must exist. This writes ops.key (private, mode 0600) and ops.pub, and
prints the configuration snippet with the public key. keygen refuses to overwrite an
existing key, because every token issued from it would stop verifying. issue refuses a
private key file readable by group or others.
The private key mints any permission for any tenant. Keep it on the machine that issues tokens, never on a node, a dashboard host or in an image. (A node's own
issuer.keyis the one exception, and the reason to mint a key of your own once a node is shared.)
2. Trust the public key on every node
security:
auth:
enabled: true
trusted_keys:
- name: ops
public_key: "RLklkcBhC7oZgzdpVSkbQKhBmkS9UE44KCaYurPJwRw="
public_key is the base64 string itself, not a path to ops.pub. Validation at load
refuses malformed base64, a key that is not 32 bytes, duplicate names, and, in a cluster,
enabled: true with no keys — each a startup failure naming the entry, not a node that
silently refuses everyone. name appears in logs; it carries no authority.
trusted_keys is a list so keys can rotate without downtime: add the new key, reissue
tokens, then remove the old one.
3. Issue tokens
mirexa-cli token issue -key ./keys/ops.key -perms READ_CANDLES,WRITE_CANDLES -validity 30m > token.txt
| Flag | Default | Meaning |
|---|---|---|
- |
(required) | private key file |
- |
(none) | comma-separated names: READ_, READ_, WRITE_, WRITE_, ADMIN_, LIST_, ADMIN_ |
- |
0 |
tenant id (signed, but not yet used for isolation) |
- |
30m |
lifetime; more than 1h is refused |
The token goes to stdout alone; the human-readable summary goes to stderr.
mirexa-cli token inspect -pub ./keys/ops.pub <token> decodes one and checks its signature.
See the mirexa-cli token reference.
4. Present the token
- Go SDK:
Options.Token, orOptions.TokenSource— a function called on every connect and reconnect, typically reading a file that something refreshes. mirexa-cli:-token-file <file>(re-read on every reconnect),-token <token>, or theMIREXA_TOKENenvironment variable.- Python SDK:
token_file=,token_source=ortoken=; see the Python SDK reference. - Dashboard:
dashboard.upstream_token_file, re-read on every reconnect.
Expiry, mid-session
Tokens live at most one hour, and a session does not outlive its token:
- A request on an expired session is refused on its next frame with
Unauthorized. - A subscriber sends nothing after subscribing, so the node arms a timer and closes the
connection at expiry. The SDK's resuming subscriber reconnects (with a fresh token from
its
TokenSource) and resumes from the last candle it received.[5] security.auth.subscriber_grace(default0) delays only that timer: an established subscription keeps receiving for the grace period past expiry, so a disconnect does not land in the same instant an orchestrator is rewriting the token file. It never admits an expired token at a handshake and never extends a writer.[6]
Renewal over the open connection
A client can hand the node a fresh token on its existing connection (a REAUTH frame) instead of reconnecting. The node checks it by exactly the handshake's rules, requires the same tenant, and replaces the session's grant and expiry. A refused renewal leaves the session as it was. If the new grant is narrower, subscriptions it no longer permits are ended.
A Go SDK client with a TokenSource renews by itself once two-thirds of the token's life
has passed (Options.DisableRenewal turns this off), so its subscriptions are not cut at
each expiry. A node that does not support renewal, or a failed renewal, falls back to the
reconnect path.[7]
Revocation
There is no per-token revocation. A leaked token is valid until it expires — at most an hour — which is why validity should be as short as practical.
What can be revoked is an issuer key, and only in a cluster: the control API's
RevokeKey records the revocation in the replicated control-plane log. Each node hands its
applied set of revoked keys to its data plane every 250 ms; from then on that key's
handshakes and renewals are refused, its established sessions are refused at their next
frame, and its subscribers are cut. The bound is one sync interval after the node applies
the entry.[8] ListRevokedKeys shows the set. On a single node, removing the key
from trusted_keys and restarting is the equivalent.
mirexa-cli tokenstill prints "no revocation: a token is valid until it expires" afterkeygenandissue. That is true of individual tokens; a cluster can additionally revoke a whole issuer key as described above.
Control-plane admin authentication
The gRPC control listener has its own switch, control.admin_auth, independent of
security.auth.enabled. With it on, every call on the listener needs a token carrying
ADMIN_CLUSTER, signed by one of the same security.auth.trusted_keys, sent as gRPC
metadata authorization: Bearer <token>:
mirexa-cli token issue -key ./keys/ops.key -perms ADMIN_CLUSTER -validity 15m
- The token is admitted by the same rule as a data-plane handshake: signature, the
cluster's revoked keys, expiry, the one-hour validity window, defined bits, and
security.max_permissions.ADMIN_CLUSTERmust be in the resulting grant.[9] - No, malformed, unsigned, revoked, expired or over-long credential →
UNAUTHENTICATED. A valid token withoutADMIN_CLUSTER→PERMISSION_DENIED, naming the permissions it does carry; one that carries it on a node whosemax_permissionsdoes not name it →PERMISSION_DENIED, namingmax_permissions. - Turning it on with no trusted keys stops the node at startup.
- A node with a routable
control.addrmust haveadmin_authon, or it refuses to start — clustered or not. A single node's listener servesDeleteStream,UpdateStreamMetadataandAcceptGap, so it is held to the same rule. - A clustered node that registers and heartbeats through peers whose control planes require
admin auth reads its credential from
cluster.admin_token_file, re-read before every request so it can be rotated in place. mirexa-clipasses the admin token with-token(orMIREXA_TOKEN) on its control commands.
A revoked key's admin token is refused within one revocation sync, exactly as its data-plane sessions are: the admin check reads the data server's own revoked set.
Defaults and recommendations
| Setting | Default | Recommendation |
|---|---|---|
security. |
true |
keep it; with no trusted_ a single node issues its own tokens |
security. |
none | a key you minted, its private half off the node; required in a cluster |
security. |
none | set it to what the node's clients need |
security. |
0 |
a few seconds if a token refresher rewrites files on a timer |
control. |
false |
true for any control listener off loopback |
token - |
30 m (max 1 h) | as short as your refresher allows |
| TLS | off | on wherever tokens cross a network: a token is a bearer credential, replayable by anyone who sees the handshake until it expires |
References
Source
auth.Keyring, key files — verification and the 0600 rule.wire.InitFrame,MaxTokenValidity, permission bits.Handshaker.admit— the one definition of what a token must satisfy.tokenRefusal— the messages a client receives.- /internal/network/reauth.go — renewal on the server.
Options.Token,TokenSource,DisableRenewal, /internal/wireclient/reauth.go.AdminAuth.Verify,requireLoopback.provisionLocalIssuer— the node's own issuer and admin token;authConflicts— the cluster refusal.- /cmd/cli/token.go,
securityOptions,resolveGrantCeiling,startRevocationSync.
Tests
TestAuth_SDKPresentsACLIIssuedToken,TestAuth_SubscriberSurvivesTokenExpiryWithoutLoss(/tests/auth_end_to_end_test.go).TestServer_GrantCeilingAppliesWithAuthDisabled,TestServer_GrantCeilingNeverWidens(/internal/network/auth_grant_test.go).TestHandshake_ExpiredTokenRejected(/internal/network/handshake_test.go).TestServer_ExpiredSessionRefusesNewWork,TestServer_ExpiredSubscriberIsDisconnected(/internal/network/auth_expiry_test.go).TestSubscriberGrace_DelaysTheCutWithoutGrantingAnything,TestSubscriberGrace_DoesNotAdmitAnExpiredToken(/internal/network/subscriber_grace_test.go).TestReauth_ARenewedSubscriptionOutlivesItsFirstToken,TestReauth_ANarrowedGrantEndsTheSubscriptionsItNoLongerPermits(/tests/auth_renewal_test.go).TestRevocation_ARevokedKeysSessionsAreRefusedOrCut(/tests/auth_revocation_test.go),TestServerBinary_AKeyRevokedThroughTheControlPlaneIsRefusedOnEveryNode(/tests/server_binary_revocation_test.go).TestAdminAuth_UnauthenticatedAndDeniedAreDifferentCodes,TestControlServer_AdminAuthGuardsEveryMethod,TestControlServer_ARoutableAddressRequiresAdminAuth,TestControlServer_ARoutableAddressRequiresAdminAuthWithoutACluster,TestAdminAuth_RefusesAKeyTheClusterRevoked,TestAdminAuth_RefusesATokenBeyondTheValidityWindow,TestAdminAuth_TheGrantCeilingApplies(/internal/control/admin_auth_test.go).TestAuthConfig_EnabledWithNoKeysLoadsOnASingleNode,TestAuthConfig_EnabledWithNoKeysIsRefusedInACluster(/internal/config/auth_validate_test.go).TestServerBinary_ANodeWithNoAuthConfigIssuesItsOwnAdminToken(/tests/server_binary_default_auth_test.go) — the default posture in the shipped binary: a tokenless client refused, the admin token accepted, the issuer kept across a restart.TestLocalIssuer_TheAdminTokenVerifiesAgainstTheConfiguredKeyring,TestLocalIssuer_ARestartKeepsTheIssuer,TestLocalIssuer_RemintsBeforeTheTokenLapses,TestLocalIssuer_NothingIsProvisionedWhenKeysAreConfiguredOrAuthIsOff(/cmd/server/local_issuer_test.go).
Further reading
External
- RFC 8032, Edwards-Curve Digital Signature Algorithm (EdDSA) — https://www.rfc-editor.org/rfc/rfc8032
- RFC 6750, OAuth 2.0 Bearer Token Usage (the
Authorization: Bearerconvention) — https://www.rfc-editor.org/rfc/rfc6750
admitToken,Handshaker.admitandrecordFailurein /internal/network/handshaker.go;tokenRefusalin /internal/network/server.go. ↩︎provisionLocalIssuerandlocalIssuer.startin /cmd/server/local_issuer.go;TestServerBinary_ANodeWithNoAuthConfigIssuesItsOwnAdminToken,TestLocalIssuer_ARestartKeepsTheIssuer,TestLocalIssuer_RemintsBeforeTheTokenLapses. ↩︎authConflictsin /internal/config/validate.go;TestAuthConfig_EnabledWithNoKeysIsRefusedInACluster. ↩︎TestServer_GrantCeilingAppliesWithAuthDisabled. ↩︎TestServer_ExpiredSubscriberIsDisconnected,TestAuth_SubscriberSurvivesTokenExpiryWithoutLoss. ↩︎TestSubscriberGrace_DelaysTheCutWithoutGrantingAnything,TestSubscriberGrace_DoesNotAdmitAnExpiredToken. ↩︎TestReauth_ARenewedSubscriptionOutlivesItsFirstToken,TestReauth_AClientWithATokenSourceRenewsBeforeItsTokenExpires. ↩︎startRevocationSyncin /cmd/server/revocation.go;TestServerBinary_AKeyRevokedThroughTheControlPlaneIsRefusedOnEveryNode. ↩︎AdminAuth.Verifyin /internal/control/admin_auth.go admits throughnetwork.Server.Admissionin /internal/network/revocation.go;TestAdminAuth_RefusesAKeyTheClusterRevoked,TestAdminAuth_TheGrantCeilingApplies. ↩︎