Documentation
¶
Overview ¶
Package ui implements the server-rendered single-operator admin UI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
Authenticator verifies a login and yields an Identity.
type AuthenticatorFunc ¶
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 ¶
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.
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)
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)