ctl

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 13 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 of mashctl.

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 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.

Functions

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 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 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 OpenAdminWith added in v0.5.6

func OpenAdminWith(prog string, cfg config.Config, extra ...nats.Option) (*madmin.Admin, context.Context, func(), error)

OpenAdminWith is OpenAdmin with extra connection options, applied after the standard ones.

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. Only the public key and the JWT's name, tags and issue time are read.

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 TopHelp added in v0.5.10

func TopHelp(prog, intro, tail string) string

TopHelp is the help of the tool itself, `mashctl --help`: Usage with intro (the sentence that says what SAP, NATS and creds are) after the usage line and tail (the global options) after the verbs. Either may be empty.

func Usage

func Usage(prog string) string

Usage is the full verb listing for prog. Each command takes a line, wrapped with a hanging indent when it is long, and its description follows indented under it, wrapped; no line passes eighty columns.

Types

type NoAdminCredsError added in v0.5.10

type NoAdminCredsError struct{ Prefix string }

NoAdminCredsError is the refusal to open the admin connection because no admin credentials are configured. Nothing was tried: it is a configuration problem, not a state of the server.

func (*NoAdminCredsError) Error added in v0.5.10

func (e *NoAdminCredsError) Error() string

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