Documentation
¶
Index ¶
- Constants
- func ApplyInstallerConfiguration(cfg *Config, b applysetup.Common) error
- func InstallerSocket(dataDir string) (string, error)
- func KyPostURL(raw string) (string, error)
- func ParseTrustedProxies(raw string) ([]netip.Prefix, error)
- type BackupConfig
- type CaptchaConfig
- type Config
- type DatabaseConfig
- type DriveConfig
- type SCIMConfig
- type SSOConfig
- type SecurityConfig
- type ServerConfig
Constants ¶
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.
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 ¶
InstallerSocket is private IPC; it is never mounted on the public HTTP router.
func KyPostURL ¶ added in v0.6.1
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 ¶
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 ¶
LoadExisting is LoadFromEnv for operator commands on an existing deployment: a missing keyfile or SQLite database is refused, never created.
func LoadFromEnv ¶
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 ¶
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.