ctl

package
v0.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ctl is the admin verb set shared by mashctl and the deprecated `mash admin`.

Index

Constants

View Source
const NotRevoked = "nothing was revoked; the key is still valid"

NotRevoked is the line printed when a command stopped before it revoked anything.

Variables

View Source
var CheckRevokeServers func(ctx context.Context, cfg config.Config) error

CheckRevokeServers, when set (mashctl sets it), confirms before a deprovision changes anything that the revocation can reach every server. An error means nothing was revoked and nothing was changed.

View Source
var IssuedMarkRevoked = func(ctx context.Context, a *madmin.Admin, user string, at time.Time) error {
	return a.MarkRevoked(ctx, user, at)
}

IssuedMarkRevoked is the write MarkRevoked makes; a test replaces it to make the write fail.

View Source
var RevokeNow = time.Now

RevokeNow is the clock a revocation takes its time from; a test replaces it.

View Source
var RevokeUsers func(ctx context.Context, cfg config.Config, users []string, stdout io.Writer, now func() time.Time) error

RevokeUsers revokes NATS user keys in the account JWT; mashctl sets it, which has the key store. The system account credentials come from MASH_SYS_CREDS or the init server's sys.creds, the server count from MASH_SERVERS. It stays nil in `mash admin`, which has neither: deprovision then only advises.

Functions

func AdminUserKey added in v0.5.0

func AdminUserKey(cfg config.Config) (string, error)

AdminUserKey is the public key of the admin user in cfg's admin credentials. Only the JWT is read; the seed is never used.

func CheckNotFutureIssued added in v0.5.0

func CheckNotFutureIssued(ctx context.Context, a *madmin.Admin, targets []RevokeTarget, at time.Time, stderr io.Writer) error

CheckNotFutureIssued refuses a revocation at time at when the issue record shows a user's JWT issued after at: NATS honours a revocation only for JWTs issued at or before it, so that JWT would stay valid. It looks at every issue time the record retains of the key, not only the latest: a reissue that keeps the key writes a new revision with a new time, and after a clock rollback the newer revision can be the earlier time while an older, future-dated JWT is still held. A key whose history is at the bucket's cap (store.IssuedHistory) may have lost its oldest revisions, so it is refused unless a retained revision is already future-dated (the usual refusal). Every target is checked before the caller writes anything, and one refused key refuses them all; nothing has been changed when it returns an error. A key whose retained history cannot be shown to be complete from the bucket's marker (store.IssuedMarkerKey, madmin.IncompleteHistoryError) is refused too, with the way forward: revoke it by hand. A key with no record at all (the bucket or the key is absent: an older deployment, a key mash did not issue) gets one warning line on stderr and the revocation goes on. A record that exists but cannot be read, or whose issued_at is missing or not a time in any retained revision, cannot be ruled out and refuses the whole command.

func HeldPublicKeys added in v0.5.0

func HeldPublicKeys(cfg config.Config, ks *ctlkeys.Authority) ([]string, error)

HeldPublicKeys is every public key mash holds for the account of cfg: the key store's operator, system, account and the admin user's key. A next submitter of a planned rotation must be none of them. Any failure to read the key store or the admin credentials is an error, so a caller refuses (fail closed).

func MarkRevoked added in v0.5.0

func MarkRevoked(ctx context.Context, a *madmin.Admin, user string, at time.Time, stderr io.Writer)

MarkRevoked notes in the issue record that user's key was revoked at at. It runs after the revocation succeeded and is best effort: a key mash never recorded is no finding, any other failure is a warning on stderr, and nothing here fails or undoes the revocation.

func NoRevokeWarning added in v0.3.3

func NoRevokeWarning(name, user string) string

NoRevokeWarning is the stderr block for a removal with --no-revoke: the user key keeps working.

func OpenAdmin added in v0.3.3

func OpenAdmin(prog string, cfg config.Config) (*madmin.Admin, context.Context, func(), error)

OpenAdmin connects to the server with the admin credentials and returns the admin handle, a context carrying the command's deadline (admin_timeout, else 30 seconds) and a func that releases both. prog is the command prefix of error text. The caller must call the func when done.

func RecordAdminCreds added in v0.5.0

func RecordAdminCreds(ctx context.Context, a *madmin.Admin, owner string, raw []byte) error

RecordAdminCreds puts the admin user held in the creds bytes raw in the issue record (kind admin, purpose issue), over a's connection. `mashctl init` uses it for the configured admin creds and `mashctl adopt --mint-admin` for the user it mints, before the creds file is written. Only the public key and the JWT's name, tags and issue time are read.

func Run

func Run(prog string, cfg config.Config, args []string, stdout, stderr io.Writer) int

Run executes one admin verb. prog is the command prefix used in usage and error text: "mashctl" or "mash admin".

func ShortKey added in v0.3.3

func ShortKey(k string) string

ShortKey is the first 8 characters of a key for messages, or all of it when it is shorter: a user key read from a directory record may be short or malformed, and slicing it must never panic.

func Usage

func Usage(prog string) string

Usage is the full verb listing for prog ("mashctl" or "mash admin").

Types

type RevokeTarget added in v0.5.0

type RevokeTarget struct {
	Name, Key string
}

RevokeTarget is a user key about to be revoked and the name to show for it in messages ("" shows the short key).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL