ctl

package
v0.3.0-rc.55 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 29 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 local admin socket: a small HTTP API on a Unix socket in the data directory, so that `beacon token …`, `machine …`, `ssh …`, `config …` and `drill …` work against the running service, which holds the database lock.

Only processes of the service's own user (or root) can connect: the socket is mode 0600 in the data directory, and on Linux and macOS the peer's user id is checked on every connection.

Index

Constants

View Source
const DrillKey = "drill"

DrillKey is where the drill's end is stored.

View Source
const EnrollTTL = 2 * 365 * 24 * time.Hour

EnrollTTL is how long a machine token lasts. A probe stops being able to write when its machine expires (the gateway checks the catalogue), so the token itself may outlive that.

View Source
const MaxDrill = 2 * time.Hour

MaxDrill is the longest a drill may run.

View Source
const MaxImport = 16 << 20

MaxImport is the largest import the socket takes.

View Source
const UserHeader = "X-Status-User"

UserHeader carries the name of the person running the command, as the client sees it. The audit log names the user the operating system says connected, where it can tell (cliActor).

Variables

View Source
var EnrollKinds = map[string]string{
	"probe":     "probe:write",
	"host":      "host:write",
	"heartbeat": "heartbeat:write",
	"rules":     "alerts:send",
}

EnrollKinds map what is enrolled to the scope of its token.

Functions

func ConfigHandler

func ConfigHandler(c Config) http.Handler

ConfigHandler serves the configuration's routes under /v1/config/, beside Handler.

func ConnContext

func ConnContext(ctx context.Context, c net.Conn) context.Context

ConnContext gives each request on the socket the peer's user id, where the listener learnt it, so that the audit log names whoever runs a command by who they are rather than by what the client says. The socket's http.Server takes it as its ConnContext.

func CurrentUser

func CurrentUser() string

CurrentUser is the name recorded in the audit log for commands run from this process.

func Dial

func Dial(ctx context.Context, path string) (*Client, Info, error)

Dial connects to the socket at path and checks that the service answers.

func DrillHandler

func DrillHandler(s DrillStore, record func(ctx context.Context, until time.Time, by string) error) http.Handler

DrillHandler serves /v1/drill, beside Handler. record, when not nil, records a drill starting (until is when it ends) or a running drill ending (until is zero) as a change event, so that the evidence of the alert a drill causes says it is one, and until when.

func Handler

func Handler(s Service, active func(location string) error, m Machines) http.Handler

Handler serves the socket's API. active reports whether a probe location exists and its machine has not expired; nil accepts any location. m is the SSH channel, nil when it is off.

func Listen

func Listen(path string) (net.Listener, error)

Listen opens the socket at path. A socket already there was left by a service that stopped (the caller holds the database lock, so no other service can be running); it is replaced. Anything else at path is an error and is left alone.

func ParseSSHKey

func ParseSSHKey(line string) (store.SSHKey, error)

ParseSSHKey reads an authorized_keys line into what a token keeps.

func ParseTTL

func ParseTTL(s string) (time.Duration, error)

ParseTTL accepts Go durations and whole days ("365d").

func Path

func Path(dataDir string) string

Path is where the socket lives in the data directory.

func PeopleHandler

func PeopleHandler(p People) http.Handler

PeopleHandler serves /v1/setup, /v1/users, /v1/agents and /v1/claims, beside Handler.

func SettingsHandler

func SettingsHandler(s Settings) http.Handler

SettingsHandler serves /v1/settings and /v1/settings/rules-token on the admin socket.

func SilenceHandler

func SilenceHandler(s Silences) http.Handler

SilenceHandler serves the silences' routes under /v1/silences, beside Handler.

func VaultHandler

func VaultHandler(v Vault) http.Handler

VaultHandler serves /v1/vault/… beside Handler.

Types

type AgentRequest

type AgentRequest struct {
	Name     string   `json:"name"`
	Owner    string   `json:"owner"`
	Preset   string   `json:"preset,omitempty"`
	Scopes   []string `json:"scopes,omitempty"`
	Machines []string `json:"machines,omitempty"`
	SSHKeys  []string `json:"ssh_keys,omitempty"`
	TTL      string   `json:"ttl"`
}

AgentRequest makes an agent for Owner with a token lasting TTL (365d, 720h). Machines is its machine access as the command line writes it (store.ParseMachineList); none when empty.

type Bastion

type Bastion interface {
	Update(ctx context.Context, who sshgate.Actor, name string, in sshgate.MachineUpdate) (sshgate.MachineView, error)
	MachineGroups() []sshgate.MachineGroupView
	SaveMachineGroup(ctx context.Context, who sshgate.Actor, g store.MachineGroup) (sshgate.MachineGroupView, error)
	DeleteMachineGroup(ctx context.Context, who sshgate.Actor, id string) error
	SetGroupMachines(ctx context.Context, who sshgate.Actor, id string, add, remove []string) (sshgate.MachineGroupView, error)
	AccessRules() []sshgate.AccessRuleView
	AccessRule(id string) (sshgate.AccessRuleView, error)
	SaveAccessRule(ctx context.Context, who sshgate.Actor, r store.AccessRule, ifVersion int64) (sshgate.AccessRuleView, error)
	DeleteAccessRule(ctx context.Context, who sshgate.Actor, id string) error
	Access(who sshgate.Actor, key string) (sshgate.SubjectAccess, error)
	Reachers(name string) ([]sshgate.Reacher, error)
	CommandRules() []store.CommandRule
	SaveCommandRule(ctx context.Context, who sshgate.Actor, r store.CommandRule, ifVersion int64) (store.CommandRule, error)
	DeleteCommandRule(ctx context.Context, who sshgate.Actor, id string) error
	Terminate(ctx context.Context, who sshgate.Actor, id, reason string) error
}

Bastion is what the SSH channel offers the socket beyond Machines.

type ClaimRequest

type ClaimRequest struct {
	Token  string `json:"token"`
	Owner  string `json:"owner"`
	Agent  string `json:"agent,omitempty"`
	Preset string `json:"preset,omitempty"`
}

ClaimRequest makes a legacy token an agent of Owner.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the running service over its socket.

func (*Client) Access

func (c *Client) Access(ctx context.Context, subject string) (sshgate.SubjectAccess, error)

Access is what a subject reaches.

func (*Client) AccessRules

func (c *Client) AccessRules(ctx context.Context) ([]sshgate.AccessRuleView, error)

AccessRules lists the access rules.

func (*Client) AddAccessRule

func (c *Client) AddAccessRule(ctx context.Context, r store.AccessRule) (sshgate.AccessRuleView, error)

AddAccessRule adds an access rule.

func (*Client) AddAgent

func (c *Client) AddAgent(ctx context.Context, in AgentRequest) (bridge.AgentCreated, error)

AddAgent makes an agent and its first token.

func (*Client) AddCommandRule

func (c *Client) AddCommandRule(ctx context.Context, r store.CommandRule) (store.CommandRule, error)

AddCommandRule adds a command rule.

func (*Client) AddMachine

func (c *Client) AddMachine(ctx context.Context, in sshgate.MachineInput) (sshgate.Added, error)

AddMachine adds a machine, pinning its host key.

func (*Client) AddSSHKey

func (c *Client) AddSSHKey(ctx context.Context, token, key string) (TokenInfo, error)

AddSSHKey gives a token a public key for the SSH channel.

func (*Client) Agents

func (c *Client) Agents(ctx context.Context) ([]bridge.AgentView, error)

Agents lists the agents.

func (*Client) CheckConfig

func (c *Client) CheckConfig(ctx context.Context) (ConfigState, error)

CheckConfig reports whether the running service's configuration passes its checks.

func (*Client) Claim

func (c *Client) Claim(ctx context.Context, in ClaimRequest) (bridge.AgentView, error)

Claim makes a legacy token an agent of a person.

func (*Client) CommandRules

func (c *Client) CommandRules(ctx context.Context) ([]store.CommandRule, error)

CommandRules lists the command rules.

func (*Client) ConfigHistory

func (c *Client) ConfigHistory(ctx context.Context, limit int) ([]store.ConfigChange, error)

ConfigHistory lists the latest changes to the configuration.

func (*Client) CreateSilence

func (c *Client) CreateSilence(ctx context.Context, in SilenceRequest) (SilenceResponse, error)

CreateSilence silences an alert group or every alert matching the request's matchers.

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, in TokenRequest) (TokenResponse, error)

CreateToken creates a token.

func (*Client) DeleteAccessRule

func (c *Client) DeleteAccessRule(ctx context.Context, id string) error

DeleteAccessRule removes an access rule.

func (*Client) DeleteCommandRule

func (c *Client) DeleteCommandRule(ctx context.Context, id string) error

DeleteCommandRule removes a command rule.

func (*Client) DeleteMachineGroup

func (c *Client) DeleteMachineGroup(ctx context.Context, id string) error

DeleteMachineGroup removes a machine group.

func (*Client) Drill

func (c *Client) Drill(ctx context.Context, duration string) (DrillState, error)

Drill starts or ends ("off") a drill.

func (*Client) DrillStatus

func (c *Client) DrillStatus(ctx context.Context) (DrillState, error)

DrillStatus reports the drill.

func (*Client) EnableAccessRule

func (c *Client) EnableAccessRule(ctx context.Context, id string, enabled bool) (sshgate.AccessRuleView, error)

EnableAccessRule switches an access rule on or off.

func (*Client) Enroll

func (c *Client) Enroll(ctx context.Context, in EnrollRequest) (TokenResponse, error)

Enroll gives a machine its gateway token.

func (*Client) ExpireSilence

func (c *Client) ExpireSilence(ctx context.Context, id string) error

ExpireSilence ends a silence now.

func (*Client) ExportConfig

func (c *Client) ExportConfig(ctx context.Context) (Export, error)

ExportConfig fetches the configuration in force as files.

func (*Client) ImportConfig

func (c *Client) ImportConfig(ctx context.Context, in ImportRequest) (store.ConfigChange, error)

ImportConfig imports files into the running service's configuration.

func (*Client) ImportMachines

func (c *Client) ImportMachines(ctx context.Context, csv []byte, commit bool) (sshgate.ImportResult, error)

ImportMachines previews a CSV file of machines, or imports it (commit).

func (*Client) Invite

func (c *Client) Invite(ctx context.Context, in InviteRequest) (bridge.LinkView, error)

Invite makes an invitation.

func (*Client) ListSilences

func (c *Client) ListSilences(ctx context.Context) ([]alertmanager.Silence, error)

ListSilences lists the silences, active and pending first as the bridge sorts them.

func (*Client) MachineGroups

func (c *Client) MachineGroups(ctx context.Context) ([]sshgate.MachineGroupView, error)

MachineGroups lists the machine groups.

func (*Client) MachineReachers

func (c *Client) MachineReachers(ctx context.Context, name string) ([]sshgate.Reacher, error)

MachineReachers lists who reaches a machine.

func (*Client) Machines

func (c *Client) Machines(ctx context.Context) (sshgate.Machines, error)

Machines lists the machines.

func (*Client) PauseSSH

func (c *Client) PauseSSH(ctx context.Context, paused bool) (SSHState, error)

PauseSSH pauses or resumes agents' access to machines.

func (*Client) RemoveAgent

func (c *Client) RemoveAgent(ctx context.Context, name string) error

RemoveAgent deletes an agent with its credentials.

func (*Client) RemoveMachine

func (c *Client) RemoveMachine(ctx context.Context, name string) error

RemoveMachine forgets a machine.

func (*Client) RemoveSSHKey

func (c *Client) RemoveSSHKey(ctx context.Context, token, fingerprint string) (TokenInfo, error)

RemoveSSHKey takes a key, by its fingerprint, from a token.

func (*Client) ResetTwoFactor

func (c *Client) ResetTwoFactor(ctx context.Context, name string) error

ResetTwoFactor takes a person's two-factor sign-in off their account.

func (*Client) ResetUser

func (c *Client) ResetUser(ctx context.Context, name string) (bridge.LinkView, error)

ResetUser makes a password reset link.

func (*Client) RevertConfig

func (c *Client) RevertConfig(ctx context.Context, in RevertRequest) (store.ConfigChange, error)

RevertConfig undoes one change.

func (*Client) RevokeToken

func (c *Client) RevokeToken(ctx context.Context, name string) error

RevokeToken deletes a token.

func (*Client) RulesToken

func (c *Client) RulesToken(ctx context.Context, rotate bool) (string, error)

RulesToken reads or rotates the rule engine's bearer token over the admin socket.

func (*Client) SSH

func (c *Client) SSH(ctx context.Context) (SSHState, error)

SSH reports the channel's state.

func (*Client) SaveMachineGroup

func (c *Client) SaveMachineGroup(ctx context.Context, g store.MachineGroup) (sshgate.MachineGroupView, error)

SaveMachineGroup adds (no ID) or changes a machine group.

func (*Client) SetAgentMachines

func (c *Client) SetAgentMachines(ctx context.Context, agent string, machines []string) (bridge.AgentView, error)

SetAgentMachines sets the machines an agent reaches, as the command line writes them (store.ParseMachineList): all, or names, each with @END optionally; none when empty.

func (*Client) SetGroupMachines

func (c *Client) SetGroupMachines(ctx context.Context, id string, add, remove []string) (sshgate.MachineGroupView, error)

SetGroupMachines puts machines in a group and takes others out.

func (*Client) SetMachineConnector

func (c *Client) SetMachineConnector(ctx context.Context, name, key string) (sshgate.MachineView, error)

SetMachineConnector sets or changes the key a machine behind NAT connects out with.

func (*Client) SetTokenMachines

func (c *Client) SetTokenMachines(ctx context.Context, token string, machines []string) (TokenInfo, error)

SetTokenMachines sets the machines a token reaches, as the command line writes them (store.ParseMachineList): all, or names; none when empty.

func (*Client) SetUserMachines

func (c *Client) SetUserMachines(ctx context.Context, username string, machines []string) (bridge.UserView, error)

SetUserMachines names the critical machines a person who is not an owner reaches (none: no more).

func (c *Client) SetupLink(ctx context.Context) (bridge.LinkView, error)

SetupLink prints the one-time link that creates the first account.

func (*Client) Terminate

func (c *Client) Terminate(ctx context.Context, id, reason string) error

Terminate ends a live session.

func (*Client) Tokens

func (c *Client) Tokens(ctx context.Context) ([]TokenInfo, error)

Tokens lists the tokens.

func (*Client) UpdateMachine

func (c *Client) UpdateMachine(ctx context.Context, name string, in sshgate.MachineUpdate) (sshgate.MachineView, error)

UpdateMachine changes a machine's settings.

func (*Client) UpdateUser

func (c *Client) UpdateUser(ctx context.Context, name string, ch bridge.UserChange) (bridge.UserView, error)

UpdateUser changes someone's role, or disables or enables them.

func (*Client) Users

func (c *Client) Users(ctx context.Context) (UsersResponse, error)

Users lists the people and the invitations not yet used.

func (*Client) VaultExport

func (c *Client) VaultExport(ctx context.Context, in VaultExportRequest) (vault.Exported, error)

VaultExport exports a collection, password-protected.

func (*Client) VaultImport

func (c *Client) VaultImport(ctx context.Context, in VaultImportRequest) (vault.ImportPreview, error)

VaultImport imports a file into a collection.

func (*Client) VaultPurge

func (c *Client) VaultPurge(ctx context.Context) (vault.SweepResult, error)

VaultPurge deletes now what the hourly sweep would.

type Config

type Config interface {
	Import(ctx context.Context, who configdb.Actor, f configdb.Files, note string, dryRun bool) (store.ConfigChange, error)
	Export() (configdb.Files, int64, error)
	History(f configdb.HistoryFilter) ([]store.ConfigChange, error)
	Revert(ctx context.Context, who configdb.Actor, version int64, note string) (store.ConfigChange, error)
	Check() error
	Warnings() []string
	Version() int64
	Summary() string
}

Config is the configuration Beacon holds, as the socket serves it for `beacon config …`.

type ConfigState

type ConfigState struct {
	Version  int64    `json:"version"`
	Summary  string   `json:"summary"`
	Problem  string   `json:"problem,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
}

ConfigState is what check-config reports of the running service's configuration. Warnings name what it refers to that Beacon does not know (a heartbeat's machine not enrolled), which is no problem.

type ConnectorKeyRequest

type ConnectorKeyRequest struct {
	Key string `json:"key"`
}

ConnectorKeyRequest sets the key a machine behind NAT connects out with (an authorized_keys line).

type DrillRequest

type DrillRequest struct {
	Duration string `json:"duration"`
}

DrillRequest starts a drill for a while, or ends it ("off").

type DrillState

type DrillState struct {
	Until    time.Time `json:"until,omitzero"`
	Run      string    `json:"run,omitempty"`
	Observed []string  `json:"observed_locations,omitempty"`
}

DrillState says until when the drill check fails.

type DrillStore

type DrillStore interface {
	SetDrill(now, until time.Time, by, detail string) (exercise.Run, bool, error)
	DrillRun() exercise.Run
	DrillObservedLocations(run string) []string
}

DrillStore keeps the drill's end and the audit log.

type EnableRequest

type EnableRequest struct {
	Enabled bool `json:"enabled"`
}

EnableRequest switches a rule on or off.

type EnrollRequest

type EnrollRequest struct {
	Kind    string `json:"kind"`    // probe, host or heartbeat
	Subject string `json:"subject"` // the location id, host name or sender name
	Rotate  bool   `json:"rotate,omitempty"`
}

EnrollRequest gives a machine its gateway token: a probe location, a host, or a heartbeat sender. An enrolled machine is enrolled again only with Rotate, which replaces its old token with the new one at once: the old token works until the new one is made and recorded.

type Export

type Export struct {
	Version int64          `json:"version"`
	Files   configdb.Files `json:"files"`
}

Export is the configuration in force as files.

type GroupMachinesRequest

type GroupMachinesRequest struct {
	Add    []string `json:"add"`
	Remove []string `json:"remove"`
}

GroupMachinesRequest puts machines in a group and takes others out.

type ImportRequest

type ImportRequest struct {
	Files  configdb.Files `json:"files"`
	Note   string         `json:"note,omitempty"`
	DryRun bool           `json:"dry_run,omitempty"`
}

ImportRequest imports files (paths as configdb.Files has them), or with DryRun says what it would change.

type Info

type Info struct {
	Version string `json:"version"`
}

Info describes the running service.

type InviteRequest

type InviteRequest struct {
	Role string `json:"role"`
	Note string `json:"note,omitempty"`
}

InviteRequest invites someone with a role.

type MachineImportRequest

type MachineImportRequest struct {
	CSV    string `json:"csv"`
	Commit bool   `json:"commit,omitempty"`
}

MachineImportRequest is a CSV file of machines to preview, or to import (Commit).

type Machines

type Machines interface {
	Add(ctx context.Context, who sshgate.Actor, in sshgate.MachineInput) (sshgate.Added, error)
	ImportMachines(ctx context.Context, who sshgate.Actor, file []byte, commit bool) (sshgate.ImportResult, error)
	Remove(ctx context.Context, who sshgate.Actor, name string) error
	List(who sshgate.Actor, address string) (sshgate.Machines, error)
	SetPaused(ctx context.Context, who sshgate.Actor, paused bool) error
	PausedSince() time.Time
	CAPublicKey() string
	HostKey() string
	SetConnector(ctx context.Context, who sshgate.Actor, name, key string) (sshgate.MachineView, error)
	// Recheck closes what is open on the channel for whoever may no longer reach it.
	Recheck() int
}

Machines is the SSH channel as the socket serves it.

type MachinesRequest

type MachinesRequest struct {
	Machines []string `json:"machines"`
}

MachinesRequest sets the machines a token reaches; empty means all.

type PauseRequest

type PauseRequest struct {
	Paused bool `json:"paused"`
}

PauseRequest pauses or resumes agents' access to machines.

type People

type People interface {
	SetupLink(via string) (bridge.LinkView, error)
	Users(who bridge.Actor) ([]bridge.UserView, []bridge.LinkView, error)
	Invite(ctx context.Context, who bridge.Actor, role, note string) (bridge.LinkView, error)
	UpdateUser(ctx context.Context, who bridge.Actor, username string, ch bridge.UserChange) (bridge.UserView, error)
	ResetLink(ctx context.Context, who bridge.Actor, username string) (bridge.LinkView, error)
	Agents(who bridge.Actor, owner string) ([]bridge.AgentView, error)
	CreateAgent(ctx context.Context, who bridge.Actor, in bridge.AgentInput) (bridge.AgentCreated, error)
	DeleteAgent(ctx context.Context, who bridge.Actor, name string) error
	ClaimToken(ctx context.Context, who bridge.Actor, token, owner, agent, preset string) (bridge.AgentView, error)
	UpdateAgent(ctx context.Context, who bridge.Actor, name string, up bridge.AgentUpdate) (bridge.AgentView, error)
	SetCriticalMachines(ctx context.Context, who bridge.Actor, username string, named store.MachineAccess) (bridge.UserView, error)
	ResetTwoFactor(ctx context.Context, who bridge.Actor, username string) error
}

People is the bridge as the socket serves it for `beacon setup`, `beacon user …`, `beacon agent …` and `beacon token claim`: the methods the console, the API and MCP call, so that what the command line does is audited and echoed like theirs. The command line on the host may do everything an owner may.

type RevertRequest

type RevertRequest struct {
	Version int64  `json:"version"`
	Note    string `json:"note,omitempty"`
}

RevertRequest undoes the change that made Version.

type RulesTokenResponse

type RulesTokenResponse struct {
	Token string `json:"token"`
}

RulesTokenResponse carries the rule engine's bearer token over the local Unix admin socket.

type SSHKeyRequest

type SSHKeyRequest struct {
	Key string `json:"key"`
}

SSHKeyRequest gives a token a public key for the SSH channel (an authorized_keys line).

type SSHState

type SSHState struct {
	Enabled          bool      `json:"enabled"`
	PausedSince      time.Time `json:"paused_since,omitzero"`
	HostKey          string    `json:"host_key,omitempty"`
	TrustedUserCAKey string    `json:"trusted_user_ca_key,omitempty"`
}

SSHState is the channel's state for `beacon ssh status`.

type Service

type Service interface {
	CreateToken(name string, scopes []string, ttl time.Duration, by string) (string, store.Token, error)
	CreateSubjectToken(name, subject string, scopes []string, ttl time.Duration, by string) (string, store.Token, error)
	Tokens() []store.Token
	UpdateToken(name string, change func(*store.Token) error) (store.Token, error)
	UpdateTokenRecorded(name string, change func(*store.Token) error, record store.Record[store.Token]) (store.Token, error)
	AddTokenSSHKey(name string, k store.SSHKey) (store.Token, error)
	AddTokenSSHKeyRecorded(name string, k store.SSHKey, record store.Record[store.Token]) (store.Token, error)
	CreateSubjectTokenRecorded(name, subject string, scopes []string, ttl time.Duration, by string, replace bool,
		record func(old *store.Token, t store.Token) []store.AuditEntry) (string, store.Token, error)
	RevokeToken(name string) error
	Audit(e store.AuditEntry) error
	SetTime(key string, t time.Time) error
	Time(key string) time.Time
	CriticalMachines() map[string]bool
}

Service is what the socket serves.

type Settings

type Settings interface {
	View() config.SettingsView
	Update(ctx context.Context, actor, via string, in config.SettingsInput) (*config.Config, config.SettingsView, error)
	RulesToken() string
	RotateRulesToken(ctx context.Context, actor, via string) (string, error)
}

Settings is what the admin socket needs from config.Manager.

type SilenceRequest

type SilenceRequest struct {
	Alert    string            `json:"alert,omitempty"`
	Matchers map[string]string `json:"matchers,omitempty"`
	Duration string            `json:"duration"`
	Comment  string            `json:"comment"`
}

SilenceRequest creates a silence for one firing alert group (Alert, its id) or for every alert whose labels equal all of Matchers; one of the two. Duration is like 4h, at most 24h; Comment says why.

type SilenceResponse

type SilenceResponse struct {
	Silence alertmanager.Silence `json:"silence"`
	Group   *bridge.GroupView    `json:"group,omitempty"`
}

SilenceResponse is the silence made and, when it was made for one alert group, that group.

type Silences

type Silences interface {
	Silence(ctx context.Context, id string, d time.Duration, who bridge.Actor, comment string) (bridge.GroupView, error)
	SilenceLabels(ctx context.Context, labels map[string]string, d time.Duration, who bridge.Actor, comment string) (alertmanager.Silence, error)
	ExpireSilence(ctx context.Context, id string, who bridge.Actor) error
	Silences(ctx context.Context) ([]alertmanager.Silence, error)
}

Silences is the bridge as the socket serves it for `beacon silence …`: the methods the API and MCP call, so that a silence made on the command line is audited and echoed like theirs.

type TerminateRequest

type TerminateRequest struct {
	Reason string `json:"reason"`
}

TerminateRequest ends a session, saying why.

type TokenInfo

type TokenInfo struct {
	Name      string    `json:"name"`
	Scopes    []string  `json:"scopes"`
	Subject   string    `json:"subject"`
	Created   time.Time `json:"created"`
	CreatedBy string    `json:"created_by"`
	Expires   time.Time `json:"expires"`
	SSHKeys   []string  `json:"ssh_keys,omitempty"`
	Lifetime  string    `json:"lifetime,omitempty"`
	Renewed   time.Time `json:"renewed,omitzero"`
	Agent     string    `json:"agent,omitempty"` // the agent whose token it is; its scopes and machines are the agent's
	bridge.MachineAccessView
}

TokenInfo is a token as the socket lists it (the hash is not interesting to people): SSHKeys are the fingerprints of its keys for the SSH channel, Machines the machines it reaches there (none: all). Lifetime is what it was created with, as token create -expires takes it; Renewed the last time it renewed itself.

type TokenRequest

type TokenRequest struct {
	Name    string   `json:"name"`
	Scopes  []string `json:"scopes"`
	TTL     string   `json:"ttl"` // such as 365d or 720h
	SSHKeys []string `json:"ssh_keys,omitempty"`
	// Machines is its machine access as the command line writes it (store.ParseMachineList): all, or
	// machine names, each with @END optionally; none when empty.
	Machines []string `json:"machines,omitempty"`
}

TokenRequest creates a token. SSHKeys (authorized_keys lines) sign in to the SSH channel; Machines limits the machines it reaches there (none: all).

type TokenResponse

type TokenResponse struct {
	Secret string      `json:"secret"`
	Token  store.Token `json:"token"`
}

TokenResponse carries the new token's secret, shown once.

type UsersResponse

type UsersResponse struct {
	Users       []bridge.UserView `json:"users"`
	Invitations []bridge.LinkView `json:"invitations"`
}

UsersResponse lists the people and the invitations not yet used.

type Vault

type Vault interface {
	CollectionByName(name string) (string, error)
	ImportAs(ctx context.Context, actor string, in vault.ImportInput) (vault.ImportPreview, error)
	ExportAs(ctx context.Context, actor, collection, exportPassword string) (vault.Exported, error)
	Sweep(ctx context.Context) (vault.SweepResult, error)
}

Vault is what `beacon vault …` needs of the vault: work on a collection without the console, for an operator on the server, recorded as the command line's user. Personal vaults stay out of reach.

type VaultExportRequest

type VaultExportRequest struct {
	Collection     string `json:"collection"`
	ExportPassword string `json:"export_password"`
}

VaultExportRequest exports a collection, sealed with ExportPassword.

type VaultImportRequest

type VaultImportRequest struct {
	Collection string `json:"collection"`
	Format     string `json:"format"`
	Content    string `json:"content"`
	Password   string `json:"password,omitempty"`
}

VaultImportRequest imports a file into a collection, named or by id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL