Documentation
¶
Index ¶
- func AuthenticationFunc(auth UserAuthenticator, apiKeyAuthenticator APIKeyAuthenticator) func(context.Context, *openapi3filter.AuthenticationInput) error
- func ClientIPFromRealIPMiddleware(trustedProxy netip.Addr, logger *slog.Logger) func(http.Handler) http.Handler
- func ClientIPFromRequestMiddleware() func(http.Handler) http.Handler
- func DevicePairingRateLimitMiddleware(requests int, window time.Duration, logger *slog.Logger) func(http.Handler) http.Handler
- func HeartbeatRateLimitMiddleware(requests int, window time.Duration, logger *slog.Logger) func(http.Handler) http.Handler
- func LoginRateLimitMiddleware(requests int, window time.Duration, logger *slog.Logger) func(http.Handler) http.Handler
- func MaxBodySizeMiddleware(maxBytes int64) func(http.Handler) http.Handler
- func NewServer(deviceHandler *DeviceHandler, authHandler *AuthHandler, ...) http.Handler
- func RequestLoggerMiddleware(_ *slog.Logger) func(http.Handler) http.Handler
- func StartAndWait(ctx context.Context, handler http.Handler, cfg ServerConfig, ...) error
- func StartPprofServer(_ context.Context, _ *slog.Logger) error
- type APIKeyAuthenticator
- type AccessLogHandler
- type AuthHandler
- type CompositeHandler
- type DeviceHandler
- type DevicePairingHandler
- type HostsHandler
- type NetworkPoliciesHandler
- type PolicyHandler
- type QueriesHandler
- type RollupHandler
- type RuleHandler
- type ServerConfig
- type UserAccessHandler
- type UserAuthenticator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthenticationFunc ¶
func AuthenticationFunc(auth UserAuthenticator, apiKeyAuthenticator APIKeyAuthenticator) func(context.Context, *openapi3filter.AuthenticationInput) error
AuthenticationFunc is called by the OapiRequestValidator to verify security schemes
func ClientIPFromRealIPMiddleware ¶
func ClientIPFromRealIPMiddleware(trustedProxy netip.Addr, logger *slog.Logger) func(http.Handler) http.Handler
ClientIPFromRealIPMiddleware extracts client IP from X-Real-IP only when the direct peer address is within trustedProxy.
If the peer is not trusted, X-Real-IP is ignored to prevent spoofing and a security warning is logged when that header is present.
func ClientIPFromRequestMiddleware ¶
ClientIPFromRequestMiddleware is middleware that extracts the client IP from r.RemoteAddr and sets it in the request context. It ignores any X-Forwarded-For headers.
func DevicePairingRateLimitMiddleware ¶ added in v0.4.0
func DevicePairingRateLimitMiddleware(requests int, window time.Duration, logger *slog.Logger) func(http.Handler) http.Handler
DevicePairingRateLimitMiddleware rate limits POST /api/v1/device-pair by client IP. When the limit fires a WARN is emitted with the client IP and path so scanning is visible in container logs.
func HeartbeatRateLimitMiddleware ¶
func HeartbeatRateLimitMiddleware(requests int, window time.Duration, logger *slog.Logger) func(http.Handler) http.Handler
HeartbeatRateLimitMiddleware rate limits POST /api/v1/heartbeat by client IP. When the limit fires a WARN is emitted with the client IP and path so scanning is visible in container logs.
func LoginRateLimitMiddleware ¶
func LoginRateLimitMiddleware(requests int, window time.Duration, logger *slog.Logger) func(http.Handler) http.Handler
LoginRateLimitMiddleware rate limits POST /api/v1/auth/login by client IP. When the limit fires a WARN is emitted with the client IP and path so brute-force attempts are visible in container logs.
func MaxBodySizeMiddleware ¶
MaxBodySizeMiddleware limits request body size to prevent large payloads from exhausting memory.
func NewServer ¶
func NewServer( deviceHandler *DeviceHandler, authHandler *AuthHandler, ruleHandler *RuleHandler, queriesHandler *QueriesHandler, policyHandler *PolicyHandler, accessLogHandler *AccessLogHandler, rollupHandler *RollupHandler, pairingHandler *DevicePairingHandler, hostsHandler *HostsHandler, userAccessHandler *UserAccessHandler, networkPoliciesHandler *NetworkPoliciesHandler, logger *slog.Logger, trustedProxy netip.Addr, ) http.Handler
func RequestLoggerMiddleware ¶
RequestLoggerMiddleware stores the request ID in context so the custom slog.Handler can stamp it on every log record produced during this request. The base logger is no longer stored in context; each handler uses its own struct-level logger.
func StartAndWait ¶
func StartAndWait(ctx context.Context, handler http.Handler, cfg ServerConfig, logger *slog.Logger) error
StartAndWait starts the HTTP server in the background. It blocks until a server error occurs or the provided context is cancelled, at which point it performs a graceful shutdown with the configured timeout.
func StartPprofServer ¶ added in v0.4.0
StartPprofServer is a no-op in the default build: the pprof debug server is compiled in only under the `pprof` build tag (see pprof_on.go). The handlers are physically absent from any binary built without the tag, so there is nothing to misconfigure or enable in a real deployment.
Types ¶
type APIKeyAuthenticator ¶
type APIKeyAuthenticator = device.APIKeyAuthenticator
type AccessLogHandler ¶
type AccessLogHandler = accesslog.HTTPHandler
type AuthHandler ¶
type AuthHandler = auth.HTTPHandler
type CompositeHandler ¶
type CompositeHandler struct {
*DeviceHandler
*AuthHandler
*RuleHandler
*QueriesHandler
*AccessLogHandler
*RollupHandler
*DevicePairingHandler
*HostsHandler
*UserAccessHandler
*PolicyHandler
*NetworkPoliciesHandler
}
type DeviceHandler ¶
type DeviceHandler = device.HTTPHandler
type DevicePairingHandler ¶ added in v0.4.0
type DevicePairingHandler = devicepairing.HTTPHandler
type HostsHandler ¶ added in v0.4.0
type HostsHandler = hosts.HTTPHandler
type NetworkPoliciesHandler ¶ added in v0.4.0
type NetworkPoliciesHandler = networkpolicies.HTTPHandler
type PolicyHandler ¶
type PolicyHandler = policy.HTTPHandler
type QueriesHandler ¶
type QueriesHandler = queries.HTTPHandler
type RollupHandler ¶ added in v0.4.0
type RollupHandler = rollup.HTTPHandler
type RuleHandler ¶
type RuleHandler = rule.HTTPHandler
type ServerConfig ¶
type ServerConfig struct {
Port int
ReadTimeout time.Duration
ReadHeaderTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
MaxHeaderBytes int
ShutdownTimeout time.Duration
}
ServerConfig holds configuration for the HTTP server lifecycle.
func DefaultServerConfig ¶
func DefaultServerConfig() ServerConfig
func DefaultServerConfigFromConf ¶
func DefaultServerConfigFromConf(port int) ServerConfig
type UserAccessHandler ¶ added in v0.4.0
type UserAccessHandler = useraccess.HTTPHandler
type UserAuthenticator ¶
type UserAuthenticator = auth.UserAuthenticator