Documentation
¶
Overview ¶
Package liteaccess implements the optional "server access key" — the DOOR that gates browser access to Tollecode Lite web mode. It is a pre-shared key, generated on and obtained FROM the machine running `tollecode web`, that a browser must present before it can reach the command bus or even begin the TOTP login. TOTP (see internal/liteauth) remains the separate LOCK that unlocks the app once you're through the door and lets a user step away.
The key is optional and off by default: on a personal machine you leave it disabled and web mode behaves exactly as before (loopback Origin + TOTP only). When enabled, a browser without the key cannot reach the login handshake — so "no server access, no key, no entry" holds even if the loopback port is forwarded onto a network. The key lives in ~/.tollecode/lite-access.json (0600), the same private directory as the TOTP secret and session tokens.
Desktop stdio mode never routes through here: that transport is trusted local IPC on a random loopback port and ignores the access key entirely, which is why a personal-PC install "doesn't need the server key".
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidKey = errors.New("invalid access key")
ErrInvalidKey is returned by Unlock when the presented key is wrong.
Functions ¶
func Allow ¶
Allow reports whether a request presenting candidate may pass the door. When no key is required (the personal-PC default) everything is allowed; otherwise candidate must equal the stored key, compared in constant time.
func Disable ¶
func Disable() error
Disable turns the door off and forgets the key; web mode reverts to TOTP-only.
func Generate ¶
Generate turns the door on with a fresh 256-bit random key and returns the plaintext so the owning machine can display it. Calling it again ROTATES the key, immediately invalidating every browser still holding the previous one.
func GrantOK ¶
GrantOK is the door check for an incoming request: allowed when no key is required, or when grant is a live grant. This is what the WS handshake and the RequireSession middleware call, with the grant read from the tc_access cookie.
func Key ¶
func Key() string
Key returns the current plaintext access key for display on the machine that owns it, or "" when the door is off. Only ever handed to an already-authorized caller (the desktop shell, or an authenticated web session in Settings).
func Required ¶
func Required() bool
Required reports whether a valid access key must be presented to use web mode: the feature is enabled AND a key has actually been generated.
func RevokeGrant ¶
func RevokeGrant(grant string)
RevokeGrant drops a single grant (used on sign-out / explicit lock).
func Unlock ¶
Unlock exchanges a correct raw key for an opaque grant token, which the caller stores in the browser (httpOnly cookie) so the raw key never persists there. Returns ("", nil) when no key is required (the door is open) — the caller then needs no grant. Returns ErrInvalidKey when the key is wrong.
func ValidateGrant ¶
ValidateGrant reports whether grant is a live (unexpired) access grant.
Types ¶
This section is empty.