Documentation
¶
Index ¶
- Constants
- func ValidateAuthConfig(auth *AuthConfig) error
- type AuthConfig
- type AuthIdentity
- type AuthTokensConfig
- type CapabilityRules
- type ClientIDMetadata
- type Config
- type DelegateEntry
- type DirConfigPermission
- type DocsetAccess
- type DocsetSpec
- type FilesConfig
- type IdentityMatch
- type InboxConfig
- type JWKSSpec
- type MTLSConfig
- type OIDCIssuer
- type OKFDocsetConfig
- type Option
- func WithAPIEnabled(enabled bool) Option
- func WithAPIPath(path string) Option
- func WithAllowKeyless(allow bool) Option
- func WithAllowedPatterns(patterns []string) Option
- func WithAuthFile(path string) Option
- func WithCAKeysFile(path string) Option
- func WithConfigFile(path string) Option
- func WithDataDir(dir string) Option
- func WithDebug(enabled bool) Option
- func WithDefaultCwd(cwd string) Option
- func WithEmbeddedConfig(data []byte, motdFallback string) Option
- func WithHTTPPort(port int) Option
- func WithHostCertFile(path string) Option
- func WithHostKeyPath(path string) Option
- func WithIgnorePatterns(patterns []string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithMCPEnabled(enabled bool) Option
- func WithMCPPath(path string) Option
- func WithMOTD(motd string) Option
- func WithMOTDFile(path string) Option
- func WithMetricsPort(port int) Option
- func WithPasskeys(pk PasskeysConfig) Option
- func WithPort(port int) Option
- func WithReadonly(readonly bool) Option
- func WithRulesTokenizer(counter tokenizer.Tokenizer) Option
- func WithSkillsDir(dir string) Option
- func WithTLS(cert, key string) Option
- func WithWritableDir(dir string) Option
- func WithWriteConflictPolicy(policy string) Option
- type PasskeysConfig
- type PathMapping
- type PluginsConfig
- type RoleSpec
- type RulesConfig
- type ShellexecCmd
- type ShellexecConfig
- type SkillsPluginConfig
Constants ¶
const DefaultInboxMaxUploadSize int64 = 10 * 1024 * 1024
Variables ¶
This section is empty.
Functions ¶
func ValidateAuthConfig ¶ added in v0.3.0
func ValidateAuthConfig(auth *AuthConfig) error
ValidateAuthConfig validates a parsed static authorization policy. Legacy authority fields are deliberately ignored.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
AllowKeyless *bool `json:"allow_keyless,omitempty"`
UnknownIdentity string `json:"unknown_identity,omitempty"`
DefaultCwd string `json:"default_cwd,omitempty"`
Rules map[string]rules.RuleSpec `json:"rules,omitempty"`
Docsets map[string]DocsetSpec `json:"docsets"`
Roles map[string]RoleSpec `json:"roles,omitempty"`
// Default is a legacy authority field retained only for JSON parsing. It is ignored.
Default map[string]string `json:"default,omitempty"`
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"`
CreatedBy string `json:"created_by,omitempty"`
ClientIDMetadata *ClientIDMetadata `json:"client_id_metadata,omitempty"`
// PublicKey is optional: an identity may exist purely as a passkey/token
// login target (no SSH key). Empty = no SSH public-key auth for this identity.
PublicKey string `json:"public_key,omitempty"`
Roles []string `json:"roles,omitempty"`
// Docsets is a legacy authority field retained only for JSON parsing. It is ignored.
Docsets map[string]string `json:"docsets"`
// Home names the docset that serves as this identity's home directory. Its
// display path becomes $HOME and the session's initial working directory.
// Home ownership provides implicit rw unless a nested docset takes precedence.
Home string `json:"home,omitempty"`
// Capabilities is a legacy authority field retained only for JSON parsing. It is ignored.
Capabilities []string `json:"capabilities,omitempty"`
// Match lists the token-claim predicates that resolve TO this identity.
// Resolution criteria live on the identity they select (rather than a
// separate rule list) since every rule maps to exactly one identity. The
// human case needs no entry: a token whose `sub` equals this identity's
// Name resolves here implicitly. WIF exchanges (jwt-bearer) match on
// `sub`/`sub_prefix`/`aud`/`claims` entries with narrowing `scope`/`ttl`.
Match []IdentityMatch `json:"match,omitempty"`
// Delegates are identities permitted to act on behalf of this principal.
// An omitted Roles field inherits all principal roles; a present field is
// intersected with the principal's roles. Denials always subtract authority.
Delegates []DelegateEntry `json:"delegates,omitempty"`
}
AuthIdentity defines a user identity and its role membership.
type AuthTokensConfig ¶ added in v0.2.0
type AuthTokensConfig struct {
Issuer string `yaml:"issuer" json:"issuer,omitempty"` // `iss` claim + JWKS base
Audience string `yaml:"audience" json:"audience,omitempty"` // required `aud`; one per instance
AccessTTL string `yaml:"access_ttl" json:"access_ttl,omitempty"` // duration string, default 1h
RefreshTTL string `yaml:"refresh_ttl" json:"refresh_ttl,omitempty"` // duration string, default 720h
}
AuthTokensConfig controls the bearer-token issuer for the MCP + HTTP API. It is server infrastructure and loaded from openlore.yml (hence yaml tags).
type CapabilityRules ¶ added in v0.3.0
type CapabilityRules struct {
Capabilities []string `json:"capabilities,omitempty"`
}
type ClientIDMetadata ¶ added in v0.5.0
type Config ¶
type Config struct {
ConfigVersion string
Debug bool
Port int
MetricsPort int
HostKeyPath string
AllowKeyless bool
UnknownIdentity string // "allow" (default) or "deny"
DefaultCwd string
MOTD string
AuthFile string
SkillsDir string
// WritableDir is the disk-backed content root layered over embedded docs.
// Its directory hierarchy is exposed directly at the virtual root.
WritableDir string
// DataDir is the server's writable control-plane data root. Distinct from
// docset content. Defaults to ./.openlore.
DataDir string
HTTPPort int
ExternalSSHPort int // advertised SSH port (for X-SSH-Port header behind a LB)
// MCPEnabled controls whether the always-on MCP-over-HTTP endpoint runs.
// Default true. The endpoint is mounted at MCPPath on the HTTP server.
MCPEnabled bool
MCPPath string
// MCPRequireAuth overrides the SSH-derived authentication posture for the
// MCP and JSON API HTTP endpoints. Nil inherits !AllowKeyless; true forces
// OAuth so HTTP clients must authenticate.
MCPRequireAuth *bool
// APIEnabled controls whether the plain JSON HTTP API (backed by the MCP
// server) runs. Default true. It is mounted at APIPath on the HTTP server.
APIEnabled bool
APIPath string
TLSCert string
TLSKey string
MTLS MTLSConfig
CAKeysFile string
HostCertFile string
Files FilesConfig
Passkeys PasskeysConfig
// Shellexec is the external-command middleware config (pre_read, pre_commit,
// post_write) run by the built-in shellexec plugin. Replaces the legacy
// event-bus `hooks` path with middleware on the read/write chains.
Shellexec ShellexecConfig
Logger *slog.Logger
Rules RulesConfig
// Readonly is the global write lock. Default true: the substrate is a
// read-only filesystem and no write verbs are available. Set false to
// enable the experimental writable substrate (SetWriteable is called at
// startup). Global readonly is a hard physical lock — a per-docset
// readonly=false cannot loosen it.
Readonly bool
// WriteConflictPolicy is the global default policy for whole-file overwrite
// verbs (`>`, tee, sed -i, publish). Default "hash" (compare-and-swap); set
// "last_write_wins" for unconditional overwrites. A per-docset override
// (DocsetSpec.WriteConflictPolicy) takes precedence for that docset.
WriteConflictPolicy vfs.WriteConflictPolicy
// MaxJobs bounds concurrent async `spawn` jobs (Part D). Default 8.
MaxJobs int
// Tokens configures bearer-token issuance/verification for the MCP + HTTP
// API. This is server infrastructure (issuer identity, audience, signing
// key, TTLs) — not per-lore access policy — so it lives in openlore.yml
// alongside passkeys, not in lore.json. When nil, token auth is disabled:
// under a public posture the MCP/HTTP endpoints serve anonymous callers
// (Phase 0); under a token-required posture (HTTPAuthRequired) they fail
// closed with 401, since no caller can present a token.
Tokens *AuthTokensConfig
Inbox InboxConfig
Plugins PluginsConfig
// OIDCIssuers are external IdPs whose JWTs may be exchanged for OpenLore
// tokens at the token endpoint via the jwt-bearer grant (workload identity
// federation). When set, each issuer's JWKS is fetched (discovery) and its
// assertions are verified and mapped to identities. Server infrastructure,
// hence openlore.yml.
OIDCIssuers []OIDCIssuer
// contains filtered or unexported fields
}
Config holds the resolved server configuration.
func New ¶
New creates a Config by applying options to the defaults. When WithConfigFile precedes WithEmbeddedConfig, a loaded file replaces the embedded config. Later options (typically CLI flags) take precedence over both.
func (Config) HTTPAuthRequired ¶ added in v0.6.1
HTTPAuthRequired resolves the authentication posture shared by MCP-over-HTTP and the JSON HTTP API. When omitted, both mirror the SSH keyless posture.
func (Config) MCPAuthRequired ¶ added in v0.3.0
MCPAuthRequired is kept for compatibility. Use HTTPAuthRequired for the shared MCP-over-HTTP and JSON API posture.
type DelegateEntry ¶ added in v0.5.0
type DelegateEntry struct {
Identity string `json:"identity"`
Roles []string `json:"roles,omitempty"`
DenyDocsets []string `json:"deny_docsets,omitempty"`
DenyCapabilities []string `json:"deny_capabilities,omitempty"`
ClientAuth string `json:"client_auth,omitempty"`
}
DelegateEntry grants an identity permission to act for a principal while capping its authority at the principal's current authority.
func (DelegateEntry) MarshalJSON ¶ added in v0.5.0
func (d DelegateEntry) MarshalJSON() ([]byte, error)
MarshalJSON preserves the semantic distinction between an omitted roles field (inherit all principal roles) and an explicitly empty list (inherit no roles). encoding/json's ordinary omitempty handling collapses those states.
type DirConfigPermission ¶ added in v0.6.0
type DirConfigPermission struct {
Edit []string `json:"edit,omitempty"`
}
type DocsetAccess ¶ added in v0.3.0
type DocsetSpec ¶
type DocsetSpec struct {
Paths []PathMapping `json:"paths"`
Access DocsetAccess `json:"access,omitempty"`
Rules map[string]rules.RuleSpec `json:"rules,omitempty"`
Config *DirConfigPermission `json:"config,omitempty"`
// AgentSkills is ignored. Collections are selected dynamically by xattr.
AgentSkills bool `json:"-"`
// Aliases are alternate display roots for the first path. They expose the
// same content while the first path remains canonical for home, inbox,
// policy, hooks, and changesets.
Aliases []string `json:"aliases,omitempty"`
// Inbox names a subfolder (VFS path, relative to a docset root or absolute)
// that the `publish` grant confines create/edit to. Empty = the docset has
// no inbox, so a `publish` grant on it can write nothing.
Inbox string `json:"inbox,omitempty"`
// MaxWriteSize caps a single write's bytes for this docset; 0 = default (2.5MB).
MaxWriteSize int64 `json:"max_write_size,omitempty"`
// Readonly is the per-docset policy check (enforced in the write pipeline,
// not on the substrate). nil means "inherit" (writable when the global lock
// is open). A docset can only further restrict: setting it true blocks
// writes to this docset even when the global lock is open; setting it false
// is meaningless when the global lock is closed.
Readonly *bool `json:"readonly,omitempty"`
// WriteConflictPolicy overrides the global write-conflict policy for writes
// to this docset. "" inherits Config.WriteConflictPolicy; "hash" forces
// compare-and-swap overwrites; "last_write_wins" forces unconditional ones.
WriteConflictPolicy string `json:"write_conflict_policy,omitempty"`
// OKF, when non-nil, activates the built-in Open Knowledge Format validator
// for this docset's subtree (see OKFDocsetConfig). nil means OKF is off for
// this docset; scope narrower subtrees with nested docsets.
OKF *OKFDocsetConfig `json:"okf,omitempty"`
}
DocsetSpec defines a named set of path mappings.
type FilesConfig ¶
FilesConfig controls which files are served.
type IdentityMatch ¶ added in v0.2.0
type IdentityMatch struct {
Sub string `json:"sub,omitempty"`
SubPrefix string `json:"sub_prefix,omitempty"`
Aud string `json:"aud,omitempty"`
Claims map[string]string `json:"claims,omitempty"`
Scope string `json:"scope,omitempty"` // narrowing scope for matched tokens (WIF)
TTL string `json:"ttl,omitempty"` // caps brokered token TTL (WIF)
}
IdentityMatch is a token-claim predicate attached to an AuthIdentity. When a verified assertion's claims satisfy it (all specified fields must hold), the assertion resolves to the enclosing identity. Exact `sub` takes precedence over `sub_prefix`/`aud`/`claims` pattern matches; `scope` narrows and `ttl` caps the brokered OpenLore token.
type InboxConfig ¶ added in v0.4.0
type JWKSSpec ¶ added in v0.2.0
type JWKSSpec struct {
Mode string `yaml:"mode" json:"mode,omitempty"` // "discovery" (default) or "url"
URL string `yaml:"url" json:"url,omitempty"` // JWKS document URL; required iff mode is "url"
}
JWKSSpec configures how an OIDC issuer's public keys are obtained. "discovery" (default) fetches them via the issuer's .well-known/openid-configuration; "url" fetches a JWKS document directly from URL, for issuers that publish keys without a discovery document (e.g. a SPIRE trust-bundle endpoint).
type MTLSConfig ¶ added in v0.5.0
type MTLSConfig struct {
CABundle string `yaml:"ca_bundle" json:"ca_bundle,omitempty"`
}
type OIDCIssuer ¶ added in v0.2.0
type OIDCIssuer struct {
IssuerURL string `yaml:"issuer_url" json:"issuer_url"`
JWKS JWKSSpec `yaml:"jwks" json:"jwks,omitempty"`
}
OIDCIssuer is an external IdP trusted for WIF token exchange. Server infrastructure, loaded from openlore.yml.
type OKFDocsetConfig ¶ added in v0.3.0
type OKFDocsetConfig struct {
// Enforce rejects non-conformant writes when true (nil → true, the default).
// When false, a non-conformant write is logged but allowed through.
Enforce *bool `json:"enforce,omitempty"`
// Patterns are globs matched against a write target's basename to select
// which files are validated. Empty defaults to ["*.md"].
Patterns []string `json:"patterns,omitempty"`
}
OKFDocsetConfig configures the built-in Open Knowledge Format validator for a docset. Its presence on a DocsetSpec activates OKF validation across that docset's subtree (defaults: enforce=true, patterns=["*.md"]).
It lives on the docset (in lore.json) rather than as a global block so OKF scoping is defined in the same place as the docset's paths and grants and can never drift from them: a write is validated by the OKF config of the docset that owns its path (the longest matching display root, exactly as authz resolves grants). Include/exclude for narrower subtrees is expressed with nested docsets — a child docset with OKF adds validation to that subtree; a child docset without OKF shadows a parent's OKF and exempts that subtree.
type Option ¶
Option is a functional option for configuring the server.
func WithAPIEnabled ¶ added in v0.2.0
WithAPIEnabled toggles the JSON HTTP API.
func WithAPIPath ¶ added in v0.2.0
WithAPIPath sets the path the JSON HTTP API is mounted at on the HTTP server (e.g. "/api").
func WithAllowKeyless ¶
WithAllowKeyless controls whether keyless SSH connections are allowed.
func WithAllowedPatterns ¶
WithAllowedPatterns sets the file patterns to serve.
func WithAuthFile ¶
WithAuthFile sets the path to the auth.json file.
func WithCAKeysFile ¶
WithCAKeysFile sets the path to a file containing trusted CA public keys for SSH certificate authentication (analogous to OpenSSH TrustedUserCAKeys).
func WithConfigFile ¶
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. Apply this option before WithEmbeddedConfig so a loaded file replaces, rather than merges with, the embedded config.
func WithDataDir ¶ added in v0.2.0
WithDataDir sets the server's writable control-plane data root.
func WithDefaultCwd ¶
WithDefaultCwd sets the default working directory for shell sessions.
func WithEmbeddedConfig ¶
WithEmbeddedConfig loads config from an embedded YAML byte slice when no config file has been loaded. WithConfigFile must be applied first when both options are used. The MOTD fallback is set separately from the config fields.
func WithHTTPPort ¶
WithHTTPPort sets the HTTP front page server port. 0 disables it.
func WithHostCertFile ¶
WithHostCertFile sets the path to the SSH host certificate file (signed by a CA, analogous to OpenSSH HostCertificate).
func WithHostKeyPath ¶
WithHostKeyPath sets the path to the SSH host key.
func WithIgnorePatterns ¶
WithIgnorePatterns sets the ignore patterns.
func WithLogger ¶
WithLogger sets the structured logger.
func WithMCPEnabled ¶ added in v0.2.0
WithMCPEnabled toggles the MCP-over-HTTP endpoint.
func WithMCPPath ¶ added in v0.2.0
WithMCPPath sets the path the MCP-over-HTTP endpoint is mounted at on the HTTP server (e.g. "/mcp").
func WithMOTDFile ¶
WithMOTDFile loads the MOTD from a file path, replacing any previous value.
func WithMetricsPort ¶
WithMetricsPort sets the metrics HTTP port. 0 disables metrics.
func WithPasskeys ¶
func WithPasskeys(pk PasskeysConfig) Option
WithPasskeys sets the passkeys configuration.
func WithReadonly ¶ added in v0.2.0
WithReadonly sets the global write lock. true (the default) keeps the substrate read-only; false enables the experimental writable substrate.
func WithRulesTokenizer ¶ added in v0.6.0
WithRulesTokenizer injects a token counter. The YAML tokenizer setting stays reserved; this option exists for embedders and compatibility tests.
func WithSkillsDir ¶
WithSkillsDir sets the directory for loading runtime skills.
func WithWritableDir ¶ added in v0.3.0
WithWritableDir sets the disk-backed content root layered over embedded docs.
func WithWriteConflictPolicy ¶ added in v0.2.0
WithWriteConflictPolicy sets the global default write-conflict policy for whole-file overwrite verbs. Empty resolves to the default (hash). Invalid values are rejected.
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 the shell (empty = same as Source)
}
PathMapping represents a path entry — either a simple string path or a source→display mapping.
func (PathMapping) MarshalJSON ¶ added in v0.3.0
func (p PathMapping) MarshalJSON() ([]byte, error)
MarshalJSON preserves the two input forms accepted by UnmarshalJSON.
func (*PathMapping) UnmarshalJSON ¶
func (p *PathMapping) UnmarshalJSON(data []byte) error
UnmarshalJSON supports both string and {"source": "display"} forms.
type PluginsConfig ¶ added in v0.4.0
type PluginsConfig struct{ Skills SkillsPluginConfig }
type RoleSpec ¶ added in v0.3.0
type RoleSpec struct {
Comment string `json:"comment,omitempty"`
Allow CapabilityRules `json:"allow,omitempty"`
Deny CapabilityRules `json:"deny,omitempty"`
}
RoleSpec is a reusable set of capabilities. Docset grants are resource-side ACL entries, not properties of the role itself.
type RulesConfig ¶ added in v0.6.0
type ShellexecCmd ¶ added in v0.2.0
type ShellexecCmd struct {
// Cmd is the shell command line to execute.
Cmd string `yaml:"cmd"`
// Timeout is a duration string (e.g. "30s") capping wall-clock runtime.
// Empty means 30s. A timeout counts as a failure.
Timeout string `yaml:"timeout"`
// FailOnError makes a non-zero exit fatal to the operation for pre_read /
// pre_commit (the read/write is aborted). Defaults to true (nil → true).
// Ignored for post_write, which never halts the log.
FailOnError *bool `yaml:"fail_on_error"`
// Debounce is a duration string coalescing repeated pre_read hits on the
// same path. Empty means 2s. Only applies to pre_read.
Debounce string `yaml:"debounce"`
// Async runs the command in the background (fire-and-forget). Default false
// (synchronous). An async pre_read / pre_commit cannot abort the operation.
Async bool `yaml:"async"`
}
ShellexecCmd is a single external command run by the shellexec plugin. It is run via `sh -c` with the OPENLORE_* env protocol.
type ShellexecConfig ¶ added in v0.2.0
type ShellexecConfig struct {
PreRead []ShellexecCmd `yaml:"pre_read"`
PreCommit []ShellexecCmd `yaml:"pre_commit"`
PostWrite []ShellexecCmd `yaml:"post_write"`
}
ShellexecConfig is the openlore.yml `shellexec:` block: external commands run as middleware on the read and write paths. pre_read runs before a read (may abort it), pre_commit runs before a write commits (may reject it), post_write runs after a durable commit (fire-and-forget: never halts the log).
func (ShellexecConfig) IsEmpty ¶ added in v0.2.0
func (c ShellexecConfig) IsEmpty() bool
IsEmpty reports whether no shellexec commands are configured.