Documentation
¶
Overview ¶
Package engine holds what one komando call is: who makes it and the state of its approvals. Today the CLI makes one call per process; the Mac and iPhone apps will run many calls in one process, for a person and for an agent at the same time, so nothing here reads the environment or a global by itself: the caller hands it in.
Index ¶
- Constants
- Variables
- func AgentName(lookup func(string) (string, bool)) string
- func AgentVars() []string
- type Call
- type Caller
- type Kind
- type Session
- func (s *Session) Allowed() bool
- func (s *Session) ApproveSafety(what string)
- func (s *Session) ConfirmDanger(key string)
- func (s *Session) DangerConfirmed(key string) bool
- func (s *Session) GaveUp() bool
- func (s *Session) Lock()
- func (s *Session) MarkShown(what string)
- func (s *Session) PersonSaidNo() bool
- func (s *Session) Reset()
- func (s *Session) SafetyApproved(what string) bool
- func (s *Session) SaidNo(no bool)
- func (s *Session) SetAllowed(allowed bool)
- func (s *Session) SetAsked(allowed bool)
- func (s *Session) SetGaveUp(g bool)
- func (s *Session) SetUnshown(why string)
- func (s *Session) SetWhy(why string)
- func (s *Session) Shown(what string) bool
- func (s *Session) Unlock()
- func (s *Session) Window() Window
- type Window
Constants ¶
const GateEnv = "KOMANDO_SSH_GATE"
GateEnv names the ssh-gate key a command came through.
Variables ¶
var GateLabel = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$`)
GateLabel is what an ssh-gate key's name may look like.
Functions ¶
Types ¶
type Call ¶ added in v0.14.0
type Call struct {
// Program is the first word of the command line ("komando"), as the
// audit log and the approval window show it.
Program string
// LookupEnv and Environ are the call's environment. The CLI passes
// os.LookupEnv and os.Environ; nil is an empty environment, also for
// the programs the call starts (a dump tool gets no PATH or HOME).
// Some programs still get the process's environment, whatever the
// call's: a kubeconfig's exec credential plugin (internal/kube), the
// openconnect a VPN runs (internal/cli/vpn_session.go), and the ones
// komando starts for itself (the approval window, the browser, a
// credential helper, background komando processes).
LookupEnv func(string) (string, bool)
Environ func() []string
// Stdin, Stdout and Stderr are the call's input and output. Stdout
// gets the JSON envelope (or the text); Stderr gets notes, warnings
// and, in text mode, errors.
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
// Terminal: a person can answer questions at the process's terminal
// (stdin and stderr are one). An app's calls have no terminal. When
// Terminal is true, Stderr must be safe for writes from several
// goroutines at once: another call's goroutine may write a notice to
// it (netx.LockBusy: a VPN is being connected elsewhere).
Terminal bool
// Ask opens the approval window for an agent's --yes,
// --allow-dangerous or --reveal; nil opens komando's own window on
// the screen.
Ask func(text string) (allowed, shown bool)
}
Call is what one komando call runs with: the environment it sees and where it reads and writes. The CLI makes one from its process (os.LookupEnv, os.Stdin, os.Stdout ...). An app that runs a person's call and an agent's call at the same time makes one for each, so what one call reads, prints or is allowed never reaches the other.
func (Call) Env ¶ added in v0.14.0
Env is the call's whole environment as KEY=value lines, for a program the call starts.
type Caller ¶
type Caller struct {
Kind Kind
Agent string // the agent's name, for the approval window and the audit log
Actor string // who the audit log names (KOMANDO_ACTOR, else the account)
}
Caller is who makes a call.
func CallerFrom ¶
CallerFrom is the caller an environment lookup describes. terminal says whether a person could answer at a terminal (stdin and stderr are one).
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is the state of one call's approvals: what a person allowed in a window, what they confirmed at a terminal. One answer covers the call, so a call that passes two checks asks once; the next call asks again.
func (*Session) ApproveSafety ¶
func (*Session) ConfirmDanger ¶
func (*Session) DangerConfirmed ¶
DangerConfirmed and its setter: a destructive action a person confirmed by typing its name.
func (*Session) Lock ¶
func (s *Session) Lock()
Lock and Unlock guard a check that reads and then sets the window state.
func (*Session) PersonSaidNo ¶
PersonSaidNo and its setter: a person answered no at a terminal, so the stop that follows is their decision, not something to retry.
func (*Session) Reset ¶ added in v0.14.0
func (s *Session) Reset()
Reset forgets every answer, as NewSession starts: the next command of the call asks again. It locks by itself, so it is safe while other goroutines read the session.
func (*Session) SafetyApproved ¶
SafetyApproved and its setter: a safety change a person allowed.