httpguard

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionNetwork

func ConnectionNetwork(ctx context.Context) string

func IsLoopbackRequest

func IsLoopbackRequest(r *http.Request) bool

IsLoopbackRequest reports whether a request originates from loopback.

func IsSameOriginBrowserRequest

func IsSameOriginBrowserRequest(r *http.Request) bool

IsSameOriginBrowserRequest reports whether a browser-originated unsafe request came from the same origin as the admin endpoint.

func LocalOnly

func LocalOnly(next http.Handler, message string) http.Handler

LocalOnly blocks non-loopback traffic with a configurable error message.

func MergeContexts

func MergeContexts(primary context.Context, secondary context.Context) context.Context

MergeContexts returns a context that is canceled when either input context is done.

func SameOriginUnsafe

func SameOriginUnsafe(next http.Handler, message string) http.Handler

SameOriginUnsafe rejects unsafe browser requests that do not originate from the admin UI origin. Requests without browser CSRF headers are allowed so local non-browser clients keep working.

func WithConnectionNetwork

func WithConnectionNetwork(ctx context.Context, network string) context.Context

func WithShutdownContext

func WithShutdownContext(next http.Handler, shutdownCtx context.Context) http.Handler

WithShutdownContext merges the request context with a shutdown context. The handler will observe cancellation from either context.

Types

type GuardedMux

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

GuardedMux wraps an http.ServeMux with loopback gating.

func NewGuardedMux

func NewGuardedMux(mux *http.ServeMux, allowRemote bool, message string) GuardedMux

NewGuardedMux constructs a GuardedMux using the supplied loopback policy.

func (GuardedMux) Handle

func (g GuardedMux) Handle(pattern string, h http.Handler)

Handle registers a pattern with loopback enforcement applied.

func (GuardedMux) HandleFunc

func (g GuardedMux) HandleFunc(pattern string, fn func(http.ResponseWriter, *http.Request))

HandleFunc registers a pattern with loopback enforcement applied.

Jump to

Keyboard shortcuts

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