Documentation
¶
Overview ¶
Package ctl is the admin verb set of mashctl.
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 OpenAdmin(prog string, cfg config.Config) (*madmin.Admin, context.Context, func(), error)
- func OpenAdminWith(prog string, cfg config.Config, extra ...nats.Option) (*madmin.Admin, context.Context, func(), error)
- func RecordAdminCreds(ctx context.Context, a *madmin.Admin, owner string, raw []byte) error
- 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 ¶
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 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, account signing 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 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 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
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.
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).