Documentation
¶
Overview ¶
Package ctl is the admin verb set of mashctl.
Index ¶
- Constants
- Variables
- func CheckNotFutureIssued(ctx context.Context, a *madmin.Admin, targets []RevokeTarget, at time.Time, ...) 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 TopHelp(prog, intro, tail string) string
- func Usage(prog string) string
- type NoAdminCredsError
- 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 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
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.
func ShortKey ¶ added in v0.3.3
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.
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).