settings

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package settings owns the user's persisted configuration (settings.json): base path, allowed hosts, auth token, masking policy, and compose-discovery config. It lives in its own package so both the server and the standalone `oriel mcp` process can read and atomically write it, the server is the usual writer, but MCP needs to set a stack alias.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bearer added in v0.6.0

func Bearer(header string) string

Bearer extracts the token from an "Authorization: Bearer <token>" header value. The scheme is case-insensitive; the token is trimmed. Returns "" if absent.

func Path

func Path() string

Path is the settings.json location.

func Save

func Save(c Settings) error

Save writes settings.json atomically.

func SetAlias

func SetAlias(name, alias string) error

SetAlias sets (or, with an empty alias, clears) the Oriel display alias for a compose project. Display only, the real project name is unchanged.

func TokenOK added in v0.6.0

func TokenOK(provided, configured string) bool

TokenOK reports whether the provided bearer token matches the configured one, in constant time so a wrong token can't be guessed byte-by-byte via timing. An empty configured token means auth is off (always OK). The single source of the security-critical compare, shared by the GUI gate and the MCP-over-HTTP gate.

func Update

func Update(mutate func(*Settings)) error

Update performs a read-modify-write under a single hold of the lock, so concurrent in-process updates to different fields can't clobber one another. Across processes (server vs. `oriel mcp`) the atomic temp+rename prevents torn files; the last writer wins, acceptable for these low-stakes fields.

Types

type Settings

type Settings struct {
	BasePath     string           `json:"basePath"` // reverse-proxy sub-path, e.g. /oriel ("" = root)
	Discovery    discovery.Config `json:"discovery"`
	AllowedHosts []string         `json:"allowedHosts"` // non-loopback Hosts allowed to reach /api
	MaskEnv      string           `json:"maskEnv"`      // inspect env masking: "all" (default) | "sensitive" | "off"
	MaskLogs     string           `json:"maskLogs"`     // UI log masking: "sensitive" (default, redact secrets) | "off". The MCP/agent path is always at least "sensitive".
	EnvReveal    string           `json:"envReveal"`    // where "reveal values" works: "local" (default) | "remote" | "off"
	AuthToken    string           `json:"authToken"`    // opt-in bearer token required for non-loopback /api ("" = off)
}

Settings is the single source of truth for everything the user configures (as opposed to colima/docker state). Persisted as settings.json and edited via the UI, the CLI, MCP, or by hand.

func Load

func Load() Settings

Load reads settings.json (zero value if missing or unreadable).

Jump to

Keyboard shortcuts

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