Documentation
¶
Index ¶
- func ConnectionNetwork(ctx context.Context) string
- func IsLoopbackRequest(r *http.Request) bool
- func IsSameOriginBrowserRequest(r *http.Request) bool
- func LocalOnly(next http.Handler, message string) http.Handler
- func MergeContexts(primary context.Context, secondary context.Context) context.Context
- func SameOriginUnsafe(next http.Handler, message string) http.Handler
- func WithConnectionNetwork(ctx context.Context, network string) context.Context
- func WithShutdownContext(next http.Handler, shutdownCtx context.Context) http.Handler
- type GuardedMux
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectionNetwork ¶
func IsLoopbackRequest ¶
IsLoopbackRequest reports whether a request originates from loopback.
func IsSameOriginBrowserRequest ¶
IsSameOriginBrowserRequest reports whether a browser-originated unsafe request came from the same origin as the admin endpoint.
func MergeContexts ¶
MergeContexts returns a context that is canceled when either input context is done.
func SameOriginUnsafe ¶
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 ¶
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.