config

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 17 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

Index

Constants

View Source
const DefaultAppName = "KyDrive"

DefaultAppName is the service name an unconfigured instance runs under. Capsules are sealed under it, so the restore CLI has to agree with it without loading a whole Config.

View Source
const MinDepositInterval = 15 * time.Minute

MinDepositInterval is the shortest schedule accepted: each run snapshots the whole database and uploads it, and KyRecovery admits 60 deposits per token per 15 minutes.

Variables

This section is empty.

Functions

func ApplyInstallerConfiguration

func ApplyInstallerConfiguration(cfg *Config, b applysetup.Common) error

ApplyInstallerConfiguration narrows an already validated setup into runtime config. Nonempty operator SSO settings are immutable to the installer.

func InstallerSocket

func InstallerSocket(dataDir string) (string, error)

InstallerSocket is private IPC; it is never mounted on the public HTTP router.

func KyPostURL added in v0.6.1

func KyPostURL(raw string) (string, error)

KyPostURL checks a KyPost base URL, from the environment or from KyIdentity, and returns it without a trailing slash: https, a host, nothing else.

func ParseTrustedProxies

func ParseTrustedProxies(raw string) ([]netip.Prefix, error)

ParseTrustedProxies parses a comma-separated list of IPs and CIDR blocks into prefixes. A bare IP becomes a single-address prefix. An unparsable entry is a startup error: a silently dropped proxy would make the server ignore its X-Forwarded-For and lump every client behind it into one rate-limit bucket.

Types

type BackupConfig

type BackupConfig struct {
	Dir string `json:"dir"`
	// Keep is how many capsule generations recoveryclient retains; it refuses values below 1.
	Keep int `json:"keep"`
	// DepositInterval is how often a paired instance seals and deposits a capsule to
	// KyRecovery. Zero disables the schedule; deposits then happen only on request.
	DepositInterval time.Duration `json:"deposit_interval"`
	// AllowPrivateRecovery admits private and CGNAT KyRecovery destinations (HTTPS still
	// required). Off by default: KyRecovery destinations must be public.
	AllowPrivateRecovery bool `json:"allow_private_recovery"`
	// CollectTimeout bounds one payload collection: database snapshot, blob verification and
	// the Restic bulk snapshot. Zero is unbounded (literal test configs only).
	CollectTimeout time.Duration `json:"collect_timeout"`
	// DrillDir is the restore drill's scratch root; DrillTimeout bounds one drill (zero is unbounded).
	DrillDir     string        `json:"drill_dir"`
	DrillTimeout time.Duration `json:"drill_timeout"`
}

BackupConfig holds parameters for KyBackup capsules & recovery drills.

type CaptchaConfig

type CaptchaConfig struct {
	Provider      string `json:"provider"` // "pow", "turnstile", "friendly", "none"
	SiteKey       string `json:"site_key"`
	SecretKey     string `json:"secret_key"`
	DifficultyPoW int    `json:"difficulty_pow"`
}

CaptchaConfig holds anti-abuse settings (PoW default, Turnstile, Friendly).

type Config

type Config struct {
	Server   ServerConfig   `json:"server"`
	Database DatabaseConfig `json:"database"`
	Security SecurityConfig `json:"security"`
	SSO      SSOConfig      `json:"sso"`
	SCIM     SCIMConfig     `json:"scim"`
	Backup   BackupConfig   `json:"backup"`
	Captcha  CaptchaConfig  `json:"captcha"`
	Drive    DriveConfig    `json:"drive"`
}

Config encapsulates all runtime configuration for kydrive-server.

func LoadExisting

func LoadExisting() (*Config, error)

LoadExisting is LoadFromEnv for operator commands on an existing deployment: a missing keyfile or SQLite database is refused, never created.

func LoadFromEnv

func LoadFromEnv() (*Config, error)

LoadFromEnv initializes a Config struct populated from environment variables with sensible defaults.

type DatabaseConfig

type DatabaseConfig struct {
	Driver          string        `json:"driver"` // "sqlite", "postgres", "mysql"
	DSN             string        `json:"dsn"`    // Connection string or file path
	DataDir         string        `json:"data_dir"`
	MaxOpenConns    int           `json:"max_open_conns"`
	MaxIdleConns    int           `json:"max_idle_conns"`
	ConnMaxLifetime time.Duration `json:"conn_max_lifetime"`
}

DatabaseConfig holds connection settings for pluggable storage (SQLite, PostgreSQL, MySQL).

type DriveConfig

type DriveConfig struct {
	MaxFileSize   int64 `json:"max_file_size"`
	MaxZipSize    int64 `json:"max_zip_size"`
	ContentSearch bool  `json:"content_search"`
	// KyPostURL (KYDRIVE_KYPOST_URL, https://host) and KyPostSecret (KYDRIVE_KYPOST_SECRET_FILE,
	// at least 32 bytes) pair KyPost from the environment; empty leaves pairing to KyIdentity.
	KyPostURL    string `json:"kypost_url,omitempty"`
	KyPostSecret []byte `json:"-"`
}

DriveConfig bounds resumable uploads and folder zip downloads, in bytes. ContentSearch (KYDRIVE_CONTENT_SEARCH, default on) runs the search index worker and matches file contents.

type SCIMConfig

type SCIMConfig struct {
	Enabled     bool   `json:"enabled"`
	BearerToken string `json:"bearer_token"`
}

SCIMConfig holds settings for RFC 7643/7644 inbound user provisioning.

type SSOConfig

type SSOConfig struct {
	Enabled            bool   `json:"enabled"`
	KySignOnIssuer     string `json:"kysignon_issuer"`
	KySignOnClientID   string `json:"kysignon_client_id"`
	KySignOnSecret     string `json:"kysignon_secret"`
	KySignOnHMACSecret string `json:"kysignon_hmac_secret"`
	GenericOIDCIssuer  string `json:"generic_oidc_issuer"`
	SAMLMetadataURL    string `json:"saml_metadata_url"`
	AutoProvision      bool   `json:"auto_provision"`
}

SSOConfig holds identity provider and federation parameters.

type SecurityConfig

type SecurityConfig struct {
	SessionSecret string `json:"session_secret"`
	EncryptionKey []byte `json:"-"` // 32 bytes for AES-256-GCM; never serialised
	CookieSecure  bool   `json:"cookie_secure"`
	CookieDomain  string `json:"cookie_domain"`
	SessionTTL    time.Duration
	// TrustedProxies is the parsed KY_TRUSTED_PROXIES allowlist. Only a request whose peer
	// address falls inside it may speak for a client other than itself.
	TrustedProxies []netip.Prefix `json:"-"`
	// RateLimitExemptNetworks is KY_RATE_LIMIT_EXEMPT_NETWORKS in netallow's canonical form:
	// office networks whose requests skip per-IP limits. The admin setting adds to it.
	RateLimitExemptNetworks string `json:"-"`
	// KeyInDataDir is set while <DataDir>/encryption.key exists, whether or not the key was
	// read from it, or while <DataDir>/drill holds residue of an interrupted recovery drill
	// (its opened capsule carries the key): a copy of the data directory then decrypts itself.
	KeyInDataDir bool `json:"-"`
	// IdentityKey signs the TLS pin statement linked devices roll over to (KYDRIVE_IDENTITY_KEY_FILE,
	// default <DataDir>/identity.key). Never rotated: devices hold its public half. nil only for
	// an operator command on a deployment whose server has not yet created it.
	IdentityKey ed25519.PrivateKey `json:"-"`
	// TLSCertFile (KYDRIVE_TLS_CERT_FILE, absolute) is the certificate the reverse proxy serves,
	// PEM, leaf first: the TLS pin statement signs only its key.
	TLSCertFile string `json:"-"`
	// TLSPinProbe (KYDRIVE_TLS_PIN_PROBE, off) signs the leaf a probe of KY_APP_URL reaches when
	// no TLSCertFile is set: for a front with no certificate to mount (Cloudflare Tunnel). Anyone
	// on the server's own path with a trusted certificate for the name gets it signed.
	TLSPinProbe bool `json:"-"`
}

SecurityConfig holds encryption keys, cookie secrets, and session settings.

type ServerConfig

type ServerConfig struct {
	Host         string        `json:"host"`
	Port         int           `json:"port"`
	AppURL       string        `json:"app_url"`
	AppName      string        `json:"app_name"`
	ReadTimeout  time.Duration `json:"read_timeout"`
	WriteTimeout time.Duration `json:"write_timeout"`
	Environment  string        `json:"environment"`
	// ExcalidrawFontsDir holds the CJK whiteboard fonts kept out of the binary; empty serves none.
	ExcalidrawFontsDir string `json:"excalidraw_fonts_dir"`
}

ServerConfig defines HTTP and network settings.

Jump to

Keyboard shortcuts

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