model

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

package model defines the core data structures used throughout Keymaster. These structs represent the entities stored in the database and used by the application logic, such as accounts, keys, and audit logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID       int    // The primary key for the account.
	Username string // The SSH username for the account.
	Hostname string // The hostname or IP address of the target machine.
	Label    string // A user-friendly alias for the account (e.g., "prod-web-01").
	Tags     string // Comma-separated key:value pairs for organization.
	// Serial is the serial number of the SystemKey last deployed to this account.
	// A value of 0 indicates the account has never been deployed to.
	Serial int
	// IsActive determines if the account is included in bulk operations like 'deploy' and 'audit'.
	IsActive bool
}

Account represents a user on a specific host (e.g., deploy@server-01). This is the core entity for which we manage access.

func (Account) String

func (a Account) String() string

String returns a user-friendly representation of the account. It formats as "Label (user@host)" if a label is present, otherwise just "user@host".

type AccountKey added in v1.4.0

type AccountKey struct {
	KeyID     int `json:"key_id"`
	AccountID int `json:"account_id"`
}

AccountKey represents the many-to-many relationship between accounts and public keys.

type AuditLogEntry

type AuditLogEntry struct {
	ID        int    // The primary key for the log entry.
	Timestamp string // The timestamp of the event (as a string for display simplicity).
	Username  string // The OS user who performed the action.
	Action    string // A category for the event (e.g., "DEPLOY_SUCCESS", "ADD_ACCOUNT").
	Details   string // A free-text description of the event.
}

AuditLogEntry represents a single event in the audit log.

type BackupData added in v1.4.0

type BackupData struct {
	// SchemaVersion helps in handling migrations during restore.
	SchemaVersion int `json:"schema_version"`

	// Data from each table.
	Accounts          []Account          `json:"accounts"`
	PublicKeys        []PublicKey        `json:"public_keys"`
	AccountKeys       []AccountKey       `json:"account_keys"`
	SystemKeys        []SystemKey        `json:"system_keys"`
	KnownHosts        []KnownHost        `json:"known_hosts"`
	AuditLogEntries   []AuditLogEntry    `json:"audit_log_entries"`
	BootstrapSessions []BootstrapSession `json:"bootstrap_sessions"`
}

BackupData is a container for all data to be exported for a backup. It holds slices of all the core models in Keymaster.

type BootstrapSession added in v1.4.0

type BootstrapSession struct {
	ID            string    // Unique session identifier.
	Username      string    // Username for the pending account.
	Hostname      string    // Hostname for the pending account.
	Label         string    // Optional label for the pending account.
	Tags          string    // Optional tags for the pending account.
	TempPublicKey string    // Temporary public key for initial access.
	CreatedAt     time.Time // When the session was created.
	ExpiresAt     time.Time // When the session expires.
	Status        string    // Current status (active, committing, completed, failed, orphaned).
}

BootstrapSession represents an ongoing bootstrap operation for a new host. Sessions track temporary keys and pending account information during the bootstrap workflow.

type KnownHost added in v1.4.0

type KnownHost struct {
	Hostname string `json:"hostname"`
	Key      string `json:"key"`
}

KnownHost represents a trusted host's public key.

type PublicKey

type PublicKey struct {
	ID        int    // The primary key for the public key.
	Algorithm string // The key algorithm (e.g., "ssh-ed25519").
	KeyData   string // The base64-encoded key data.
	Comment   string // The unique comment associated with the key, used as an identifier.
	// IsGlobal indicates if the key should be deployed to all active accounts by default.
	IsGlobal bool
}

PublicKey represents a single SSH public key stored in the database.

func (PublicKey) String

func (k PublicKey) String() string

String returns the full public key line suitable for an authorized_keys file.

type SystemKey

type SystemKey struct {
	ID         int    // The primary key for the system key.
	Serial     int    // A unique, auto-incrementing number identifying this key version.
	PublicKey  string // The public part of the key in authorized_keys format.
	PrivateKey string // The private part of the key in PEM format.
	// IsActive indicates if this is the current key for new deployments. Only one key can be active.
	IsActive bool
}

SystemKey represents a key pair used by Keymaster itself for deployment. The private key is stored to allow for agentless operation.

Jump to

Keyboard shortcuts

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