config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	AllowKeyless    *bool                 `json:"allow_keyless,omitempty"`
	UnknownIdentity string                `json:"unknown_identity,omitempty"`
	DefaultCwd      string                `json:"default_cwd,omitempty"`
	Docsets         map[string]DocsetSpec `json:"docsets"`
	Lore            map[string][]string   `json:"lore"`
	Identities      []AuthIdentity        `json:"identities"`
}

AuthConfig is loaded from lore.json.

func LoadAuthConfig

func LoadAuthConfig(path string) (*AuthConfig, error)

LoadAuthConfig loads auth configuration from a JSON file.

type AuthIdentity

type AuthIdentity struct {
	Name      string   `json:"name"`
	Comment   string   `json:"comment,omitempty"`
	PublicKey string   `json:"public_key"`
	Lore      string   `json:"lore"`
	Publish   []string `json:"publish,omitempty"` // writable docsets; empty = all in lore
}

AuthIdentity defines a user identity with access to a lore spec.

type Config

type Config struct {
	ConfigVersion   string
	Port            int
	MetricsPort     int
	HostKeyPath     string
	AllowKeyless    bool
	UnknownIdentity string // "allow" (default) or "deny"
	DefaultCwd      string
	MOTD            string
	AuthFile        string
	SkillsDir       string
	HTTPPort        int
	ExternalSSHPort int // advertised SSH port (for X-SSH-Port header behind a LB)
	TLSCert         string
	TLSKey          string
	CAKeysFile      string
	HostCertFile    string
	Files           FilesConfig
	Folders         []FolderConfig
	Passkeys        PasskeysConfig
	Logger          *slog.Logger
	// contains filtered or unexported fields
}

Config holds the resolved server configuration.

func New

func New(opts ...Option) (Config, error)

New creates a Config by applying options to the defaults. Returns an error if both a config file and embedded config are used.

type DocsetSpec

type DocsetSpec struct {
	Paths          []PathMapping `json:"paths"`
	PublishDir     string        `json:"publish_dir,omitempty"`
	MaxPublishSize int64         `json:"max_publish_size,omitempty"` // bytes; 0 = use default (2.5MB)
}

DocsetSpec defines a named set of path mappings.

type FilesConfig

type FilesConfig struct {
	Allowed []string
	Denied  []string
	Ignore  []string
}

FilesConfig controls which files are served.

type FolderConfig

type FolderConfig struct {
	Name string
	Path string
}

FolderConfig defines an additional named folder mount.

type Option

type Option func(*Config) error

Option is a functional option for configuring the server.

func WithAllowKeyless

func WithAllowKeyless(allow bool) Option

WithAllowKeyless controls whether keyless SSH connections are allowed.

func WithAllowedPatterns

func WithAllowedPatterns(patterns []string) Option

WithAllowedPatterns sets the file patterns to serve.

func WithAuthFile

func WithAuthFile(path string) Option

WithAuthFile sets the path to the auth.json file.

func WithCAKeysFile

func WithCAKeysFile(path string) Option

WithCAKeysFile sets the path to a file containing trusted CA public keys for SSH certificate authentication (analogous to OpenSSH TrustedUserCAKeys).

func WithConfigFile

func WithConfigFile(path string) Option

WithConfigFile loads configuration from a YAML file. Fields in the file override defaults. If the file does not exist, no error is returned and the config is unchanged.

func WithDefaultCwd

func WithDefaultCwd(cwd string) Option

WithDefaultCwd sets the default working directory for shell sessions.

func WithEmbeddedConfig

func WithEmbeddedConfig(data []byte, motdFallback string) Option

WithEmbeddedConfig loads config from an embedded YAML byte slice. The MOTD fallback is set separately from the config fields.

func WithHTTPPort

func WithHTTPPort(port int) Option

WithHTTPPort sets the HTTP front page server port. 0 disables it.

func WithHostCertFile

func WithHostCertFile(path string) Option

WithHostCertFile sets the path to the SSH host certificate file (signed by a CA, analogous to OpenSSH HostCertificate).

func WithHostKeyPath

func WithHostKeyPath(path string) Option

WithHostKeyPath sets the path to the SSH host key.

func WithIgnorePatterns

func WithIgnorePatterns(patterns []string) Option

WithIgnorePatterns sets the ignore patterns.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the structured logger.

func WithMOTD

func WithMOTD(motd string) Option

WithMOTD sets the message of the day, replacing any previous value.

func WithMOTDFile

func WithMOTDFile(path string) Option

WithMOTDFile loads the MOTD from a file path, replacing any previous value.

func WithMetricsPort

func WithMetricsPort(port int) Option

WithMetricsPort sets the metrics HTTP port. 0 disables metrics.

func WithPasskeys

func WithPasskeys(pk PasskeysConfig) Option

WithPasskeys sets the passkeys configuration.

func WithPort

func WithPort(port int) Option

WithPort sets the SSH server port.

func WithSkillsDir

func WithSkillsDir(dir string) Option

WithSkillsDir sets the directory for loading runtime skills.

func WithTLS

func WithTLS(cert, key string) Option

WithTLS sets TLS certificate and key paths for the HTTP server.

type PasskeysConfig

type PasskeysConfig struct {
	Enabled      bool
	RPID         string
	RPName       string
	RPOrigins    []string
	LorePath     string
	PasskeysFile string
	SessionTTL   string // parsed as time.Duration
}

PasskeysConfig holds WebAuthn passkey configuration.

type PathMapping

type PathMapping struct {
	Source  string // the real path (relative to root dir or assets/lore)
	Display string // the path shown in bashfs (empty = same as Source)
}

PathMapping represents a path entry — either a simple string path or a source→display mapping.

func (*PathMapping) UnmarshalJSON

func (p *PathMapping) UnmarshalJSON(data []byte) error

UnmarshalJSON supports both string and {"source": "display"} forms.

Jump to

Keyboard shortcuts

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