control

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: GPL-3.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package control implements Astra Admin Control WebSocket protocol v1.

Index

Constants

View Source
const (
	ProtocolVersion   = 1
	CloseProtocol     = 4400
	CloseUnauthorized = 4401
	CloseForbidden    = 4403
	CloseUnavailable  = 4503
)

Variables

View Source
var ErrRateLimited = errors.New("control ticket rate limited")
View Source
var ErrUISourceUnavailable = errors.New("admin UI source unavailable")

Functions

This section is empty.

Types

type AuditFunc

type AuditFunc func(actor, action, target string, metadata map[string]any)

type Config

type Config struct {
	AllowedOrigins           []string
	AuthTimeout              time.Duration
	HeartbeatInterval        time.Duration
	PongTimeout              time.Duration
	WriteTimeout             time.Duration
	MaxConnections           int
	MaxConnectionsPerSession int
	MaxTicketsPerMinute      int
}

type RevisionSource

type RevisionSource func() Revisions

type Revisions

type Revisions struct{ Modules, UI uint64 }

type Server

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

func New

func New(config Config, tickets TicketService) (*Server, error)

func (*Server) Attach

func (s *Server) Attach(revisions RevisionSource, audit AuditFunc)

func (*Server) AttachOperations

func (s *Server) AttachOperations(executor *operations.Executor)

AttachOperations enables the explicitly negotiated Operations v1 extension. A nil executor leaves base Control v1 behavior unchanged.

func (*Server) CloseSession

func (s *Server) CloseSession(sessionID string)

CloseSession is retained for trusted callers that already completed an authoritative revoke. New mutation paths should prepare before storage.

func (*Server) Discovery

func (s *Server) Discovery() map[string]any

func (*Server) Issue

func (s *Server) Issue(ctx context.Context, authentication *auth.IdentityAuthentication) (*auth.IssuedControlTicket, error)

func (*Server) NotifyModules

func (s *Server) NotifyModules(revision uint64)

func (*Server) NotifyPluginChanged

func (s *Server) NotifyPluginChanged(name string)

NotifyPluginChanged tells authenticated clients to refetch plugin state.

func (*Server) NotifyUI

func (s *Server) NotifyUI(revision uint64)

func (*Server) NotifyUISourceChanged

func (s *Server) NotifyUISourceChanged(provider, source, key string) error

NotifyUISourceChanged publishes a server-authorized source invalidation.

func (*Server) PrepareSessionRevocation

func (s *Server) PrepareSessionRevocation(sessionID string) *SessionRevocation

PrepareSessionRevocation marks a session before its authoritative storage mutation, preventing reconcile from independently auditing the same revoke.

func (*Server) RegisterUISource

func (s *Server) RegisterUISource(provider, source, requiredPermission string) error

RegisterUISource installs the trusted audience for one declarative source. Registration is startup-only and becomes immutable on the first ServeHTTP.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

type SessionRevocation

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

SessionRevocation is a single-use two-phase marker around an authoritative session revocation. Prepare must happen before storage mutation.

func (*SessionRevocation) Commit

func (r *SessionRevocation) Commit()

Commit closes the exact marked session after durable revocation succeeds.

func (*SessionRevocation) Rollback

func (r *SessionRevocation) Rollback()

Rollback removes this attempt's marker after durable revocation fails or is a no-op. Concurrent prepared/committed attempts retain their protection.

Jump to

Keyboard shortcuts

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