server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package server owns the bounded administrative HTTP server lifecycle.

Index

Constants

View Source
const (
	// APIKeyIDHeader carries the non-secret static key identifier.
	APIKeyIDHeader = "X-Queue-Control-Key-ID" //nolint:gosec // A protocol header name, not a credential.
	// APIKeySecretHeader carries the static key credential.
	APIKeySecretHeader = "X-Queue-Control-Key" //nolint:gosec // A protocol header name, not a credential.
)

Variables

View Source
var ErrInvalidAccessDocument = errors.New("server: invalid access document")

ErrInvalidAccessDocument is a secret-safe static access configuration error.

View Source
var ErrInvalidConfiguration = errors.New("server: invalid configuration")

Functions

func NewAdministrativeHandler

func NewAdministrativeHandler(
	api http.Handler,
	extractor authhttp.CredentialExtractor,
	authenticator authentication.Authenticator,
	challenge authentication.Challenge,
	securityConfig apihttp.SecurityConfig,
) (http.Handler, error)

NewAdministrativeHandler composes browser admission and fail-closed authentication middleware around the administrative API. Missing credentials become an explicit anonymous principal so health endpoints can remain public; administrative endpoints still reject that principal.

Types

type Config

type Config struct {
	ReadHeaderTimeout time.Duration
	ReadTimeout       time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	ShutdownTimeout   time.Duration
	MaxHeaderBytes    int
}

Config bounds HTTP admission and graceful shutdown.

type Server

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

Server serves one preconfigured listener without supervising other processes.

func New

func New(listener net.Listener, handler http.Handler, config Config) (*Server, error)

New creates a bounded administrative HTTP server.

func (*Server) Run

func (server *Server) Run(ctx context.Context) error

Run serves until the listener fails or ctx requests graceful shutdown.

type StaticAccess

type StaticAccess struct {
	Extractor     *authhttp.Extractor
	Authenticator authentication.Authenticator
	Authorizer    *controlauthz.Authorizer
	Challenge     authentication.Challenge
}

StaticAccess is a coherent authentication and authorization configuration.

func LoadStaticAccess

func LoadStaticAccess(reader io.Reader, maxBytes int64) (*StaticAccess, error)

LoadStaticAccess reads one strict, bounded JSON access document without retaining or formatting its source bytes in errors.

func LoadStaticAccessFile

func LoadStaticAccessFile(path string, maxBytes int64) (*StaticAccess, error)

LoadStaticAccessFile opens one access document without disclosing its path or contents through returned errors.

func NewStaticAccess

func NewStaticAccess(keys []apikey.Entry, entries []acl.Entry) (*StaticAccess, error)

NewStaticAccess builds bounded API-key authentication and deny-overrides ACL authorization from immutable startup configuration.

Jump to

Keyboard shortcuts

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