admin

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package admin provides an owner-only web UI for managing the hold service. It includes OAuth-based authentication, crew management, settings configuration, and usage metrics. The admin panel is embedded directly in the hold service binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminConfig

type AdminConfig struct {
	// Enabled controls whether the admin panel is accessible
	Enabled bool
	// PublicURL is the hold's public URL (for DID resolution, AppView communication)
	PublicURL string
	// ConfigPath is the path to the YAML config file (empty = env-only mode)
	ConfigPath string
}

AdminConfig holds admin panel configuration

func DefaultAdminConfig

func DefaultAdminConfig() AdminConfig

DefaultAdminConfig returns sensible defaults

type AdminSession

type AdminSession struct {
	DID       string
	Handle    string
	CSRFToken string
	CreatedAt time.Time
	UserAgent string
	IPPrefix  string
}

AdminSession represents an authenticated admin session. UserAgent and IPPrefix are captured at login and rechecked on every request — a stolen token replayed from a different browser or network prefix is rejected and the session is torn down. Binding at /24 (IPv4) / /64 (IPv6) tolerates DHCP renewals within a prefix without inviting cross-network replay.

type AdminUI

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

AdminUI manages the admin web interface

func NewAdminUI

func NewAdminUI(ctx context.Context, holdPDS *pds.HoldPDS, quotaMgr *quota.Manager, garbageCollector *gc.GarbageCollector, cfg AdminConfig) (*AdminUI, error)

NewAdminUI creates a new admin UI instance

func (*AdminUI) Close

func (ui *AdminUI) Close() error

Close cleans up resources (no-op now, but keeps interface consistent)

func (*AdminUI) RegisterRoutes

func (ui *AdminUI) RegisterRoutes(r chi.Router)

RegisterRoutes registers all admin routes with the router

type CrewMemberView

type CrewMemberView struct {
	RKey         string
	DID          string
	Handle       string
	Role         string
	Permissions  []string
	Tier         string
	TierLimit    string
	CurrentUsage int64
	UsageHuman   string
	UsagePercent int
	AddedAt      time.Time
}

CrewMemberView represents a crew member for display (populated row)

type DashboardStats

type DashboardStats struct {
	TotalCrewMembers int
	TierDistribution map[string]int
}

DashboardStats contains dashboard statistics

type Flash

type Flash struct {
	Category string // "success", "error", "warning", "info"
	Message  string
}

Flash represents a flash message

type PageData

type PageData struct {
	Title      string
	ActivePage string
	User       *AdminSession
	HoldDID    string
	Flash      *Flash
	// CSRFToken is the per-session token that forms and htmx must echo back
	// on state-mutating requests. Threaded to <body hx-headers=...> at the
	// layout level; plain forms emit it via {{ csrfInput .CSRFToken }}.
	CSRFToken string
}

PageData contains common data for all admin pages

type RelayCrawlResultView

type RelayCrawlResultView struct {
	Name    string
	URL     string
	Success bool
	Error   string
}

RelayCrawlResultView is the data for a single relay crawl result row.

type RelayStatusView

type RelayStatusView struct {
	Name                     string
	URL                      string
	Online                   bool
	Error                    string
	HasRequestCrawl          bool
	RequestCrawlStatus       int
	HasListReposByCollection bool
	RepoStatus               *atproto.RepoStatus
	HostStatus               *atproto.HostStatus
	CurrentRev               string
}

RelayStatusView is the HTMX partial data returned after probing a relay.

type RelayView

type RelayView struct {
	Name string
	URL  string
}

RelayView represents a relay for the initial page render (before status check).

type StorageStats

type StorageStats struct {
	TotalBlobs    int    `json:"totalBlobs"`
	TotalSize     int64  `json:"totalSize"`
	TotalHuman    string `json:"totalHuman"`
	UniqueDigests int    `json:"uniqueDigests"`
}

StorageStats contains storage statistics

type TierOption

type TierOption struct {
	Key   string
	Name  string
	Limit string
}

TierOption represents a tier choice in forms

type UserUsage

type UserUsage struct {
	DID        string `json:"did"`
	Handle     string `json:"handle"`
	Usage      int64  `json:"usage"`
	UsageHuman string `json:"usageHuman"`
	BlobCount  int    `json:"blobCount"`
}

UserUsage represents storage usage for a user

Jump to

Keyboard shortcuts

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