ui

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package ui implements the server-rendered single-operator admin UI.

Index

Constants

This section is empty.

Variables

View Source
var ErrAuth = errors.New("invalid credentials")

ErrAuth is returned for any failed login (unknown user or bad password); callers must not distinguish the two (avoids user enumeration).

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Authenticate(user, password string) (Identity, error)
}

Authenticator verifies a login and yields an Identity.

type AuthenticatorFunc

type AuthenticatorFunc func(user, password string) (Identity, error)

AuthenticatorFunc adapts a function to the Authenticator interface.

func (AuthenticatorFunc) Authenticate

func (f AuthenticatorFunc) Authenticate(user, password string) (Identity, error)

type Config

type Config struct {
	Svc        *instance.Service
	Jobs       store.JobStore
	Auth       Authenticator
	Sessions   SessionStore
	SessionTTL time.Duration
	Secure     bool // set Secure flag on the session cookie (true in production)
}

New wires the UI's dependencies. New defaults SessionTTL (12h) and Sessions (an in-process MemorySessionStore) when they are left zero/nil. Auth is NOT defaulted — the caller must supply it before serving authenticated routes (the binary wires the single-operator Authenticator). New still succeeds with a nil Auth so the UI can be constructed for template-only tests that never exercise login.

type Identity

type Identity struct {
	Subject string
	Scopes  []string
}

Identity is the authenticated subject and its scopes, carried in the request context. Single-operator yields one fixed subject with the full scope set; future RBAC yields per-user subjects and scopes.

func (Identity) HasScope

func (i Identity) HasScope(want string) bool

HasScope reports whether the identity holds want (supporting the "*" wildcard the operator identity is granted).

type MemorySessionStore

type MemorySessionStore struct {
	// contains filtered or unexported fields
}

MemorySessionStore is an in-process session store with a sliding TTL.

func NewMemorySessionStore

func NewMemorySessionStore(ttl time.Duration) *MemorySessionStore

func (*MemorySessionStore) Create

func (s *MemorySessionStore) Create(id Identity) (string, error)

func (*MemorySessionStore) Delete

func (s *MemorySessionStore) Delete(tok string)

func (*MemorySessionStore) Lookup

func (s *MemorySessionStore) Lookup(tok string) (Identity, bool)

type OperatorAuthenticator

type OperatorAuthenticator struct {
	// contains filtered or unexported fields
}

OperatorAuthenticator authenticates the single configured operator against an argon2id password hash.

func NewOperatorAuthenticator

func NewOperatorAuthenticator(op config.Operator) *OperatorAuthenticator

func (*OperatorAuthenticator) Authenticate

func (a *OperatorAuthenticator) Authenticate(user, password string) (Identity, error)

type SessionStore

type SessionStore interface {
	Create(id Identity) (token string, err error)
	Lookup(token string) (Identity, bool)
	Delete(token string)
}

SessionStore persists active sessions. In-process now; swappable later.

type UI

type UI struct {
	// contains filtered or unexported fields
}

UI holds parsed templates and dependencies and produces the /ui sub-router.

func New

func New(cfg Config) (*UI, error)

func (*UI) Handler

func (u *UI) Handler() http.Handler

Handler returns the /ui sub-router.

Jump to

Keyboard shortcuts

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