Documentation
¶
Overview ¶
Package web provides HTTP handlers for the web UI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuditTemplateFuncs ¶ added in v0.18.0
AuditTemplateFuncs returns template functions for audit templates.
Types ¶
type AuditHandler ¶ added in v0.18.0
type AuditHandler struct {
// contains filtered or unexported fields
}
AuditHandler handles audit log web UI requests.
func NewAuditHandler ¶ added in v0.18.0
func NewAuditHandler(auditStore AuditStore, auth AuthProvider, h *Handler) *AuditHandler
NewAuditHandler creates a new audit handler.
func (*AuditHandler) HandleAuditPage ¶ added in v0.18.0
func (h *AuditHandler) HandleAuditPage(w http.ResponseWriter, r *http.Request)
HandleAuditPage handles GET /audit - renders full audit page.
func (*AuditHandler) HandleAuditTable ¶ added in v0.18.0
func (h *AuditHandler) HandleAuditTable(w http.ResponseWriter, r *http.Request)
HandleAuditTable handles GET /web/audit - returns audit table partial for HTMX.
type AuditLogger ¶ added in v0.18.0
type AuditLogger interface {
LogAudit(ctx context.Context, entry store.AuditEntry) error
}
AuditLogger defines the interface for audit log storage.
type AuditStore ¶ added in v0.18.0
type AuditStore interface {
QueryAudit(ctx context.Context, q store.AuditQuery) ([]store.AuditEntry, int, error)
}
AuditStore defines the interface for audit log queries.
type AuthProvider ¶
type AuthProvider interface {
Enabled() bool
GetSessionUser(ctx context.Context, token string) (string, bool)
FilterUserKeys(username string, keys []string) []string
CheckUserPermission(username, key string, write bool) bool
UserCanWrite(username string) bool
IsAdmin(username string) bool
IsValidUser(username, password string) bool
CreateSession(ctx context.Context, username string) (string, error)
InvalidateSession(ctx context.Context, token string)
LoginTTL() time.Duration
}
AuthProvider defines the interface for authentication operations.
type Deps ¶ added in v0.19.0
type Deps struct {
Store KVStore
Auth AuthProvider
Validator Validator
Git GitService // optional
Audit AuditLogger // optional
Events EventPublisher // optional
}
Deps holds dependencies for the web handler.
type EventPublisher ¶ added in v0.19.0
type EventPublisher interface {
Publish(key string, action enum.AuditAction)
}
EventPublisher defines the interface for publishing key change events.
type GitService ¶
type GitService interface {
Commit(req git.CommitRequest) error
Delete(key string, author git.Author) error
History(key string, limit int) ([]git.HistoryEntry, error)
GetRevision(key string, rev string) ([]byte, string, error)
}
GitService defines the interface for git operations.
type Handler ¶
Handler handles web UI requests.
func (*Handler) Register ¶
func (h *Handler) Register(r *routegroup.Bundle)
Register registers web UI routes on the given router.
func (*Handler) RegisterAuth ¶
func (h *Handler) RegisterAuth(r *routegroup.Bundle)
RegisterAuth registers auth routes (login/logout) on the given router.
func (*Handler) RegisterLogin ¶
RegisterLogin registers the login POST handler with custom middleware.
type Highlighter ¶
type Highlighter struct{}
Highlighter provides syntax highlighting for code.
func NewHighlighter ¶
func NewHighlighter() *Highlighter
NewHighlighter creates a new Highlighter instance.
type KVStore ¶
type KVStore interface {
GetWithFormat(ctx context.Context, key string) ([]byte, string, error)
GetInfo(ctx context.Context, key string) (store.KeyInfo, error)
Set(ctx context.Context, key string, value []byte, format string) (created bool, err error)
SetWithVersion(ctx context.Context, key string, value []byte, format string, expectedVersion time.Time) error
Delete(ctx context.Context, key string) error
List(ctx context.Context, filter enum.SecretsFilter) ([]store.KeyInfo, error)
SecretsEnabled() bool
}
KVStore defines the interface for key-value storage operations.