Documentation
¶
Overview ¶
Package ctl is the admin verb set shared by mashctl and the deprecated `mash admin`.
Index ¶
- Constants
- Variables
- func AdminUserKey(cfg config.Config) (string, error)
- func CheckNotFutureIssued(ctx context.Context, a *madmin.Admin, targets []RevokeTarget, at time.Time, ...) error
- func HeldPublicKeys(cfg config.Config, ks *ctlkeys.Authority) ([]string, error)
- func MarkRevoked(ctx context.Context, a *madmin.Admin, user string, at time.Time, ...)
- func NoRevokeWarning(name, user string) string
- func OpenAdmin(prog string, cfg config.Config) (*madmin.Admin, context.Context, func(), error)
- func RecordAdminCreds(ctx context.Context, a *madmin.Admin, owner string, raw []byte) error
- func Run(prog string, cfg config.Config, args []string, stdout, stderr io.Writer) int
- func ShortKey(k string) string
- func Usage(prog string) string
- type RevokeTarget
Constants ¶
const NotRevoked = "nothing was revoked; the key is still valid"
NotRevoked is the line printed when a command stopped before it revoked anything.
Variables ¶
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.
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.
var RevokeNow = time.Now
RevokeNow is the clock a revocation takes its time from; a test replaces it.
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
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
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
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
NoRevokeWarning is the stderr block for a removal with --no-revoke: the user key keeps working.
func OpenAdmin ¶ added in v0.3.3
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
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 ¶
Run executes one admin verb. prog is the command prefix used in usage and error text: "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).