proxy

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package proxy owns the UI's fixed upstream routes, browser credential exchange, CSRF checks and response filtering. Bootstrap injects the session store and HTTP client; callers cannot supply arbitrary proxy destinations.

Index

Constants

View Source
const (
	DefaultRuntimeUpstream   = "http://mcp-runtime-api.mcp-platform.svc.cluster.local:8084"
	DefaultAnalyticsUpstream = "http://mcp-analytics-api.mcp-observability.svc.cluster.local:8085"
	SessionAPIPrefix         = "/api/ui/v1"
)
View Source
const CSRFHeaderName = "X-CSRF-Token"

CSRF protection for the cookie-backed UI session proxy.

The session cookie is SameSite=Strict, which already blocks the common cross-site form/fetch vectors, but SameSite is a defense-in-depth control rather than a guarantee: it is browser-enforced, has historically varied across implementations, and does nothing for a same-site subdomain attacker. Any state-changing route reached with an ambient cookie therefore carries its own token.

This is a synchroniser-token scheme rather than a double-submit cookie: the authoritative token lives in the server-side session record, so an attacker who can set cookies on the origin still cannot forge a matching pair. The token is handed to same-origin JavaScript in the /auth/login and /auth/status bodies; the same-origin policy is what keeps a cross-origin page from reading it.

Variables

This section is empty.

Functions

func NewGrafanaProxy

func NewGrafanaProxy(platformBase, runtimeBase *url.URL, store *session.Store, prefix string, httpClient *http.Client) http.Handler

The platform session is the only browser credential accepted here. Every request is reauthenticated by runtime-api, including admin requests, so a stale UI role or a surviving Grafana cookie never grants data access.

func NewHTTPClient

func NewHTTPClient() *http.Client

NewHTTPClient retains the browser proxy's bounded, non-redirecting transport.

func ParseUpstream

func ParseUpstream(raw string) (*url.URL, error)

Types

type SessionProxy

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

func NewSessionProxy

func NewSessionProxy(platformBase, runtimeBase, analyticsBase *url.URL, store *session.Store, httpClient *http.Client) *SessionProxy

func (*SessionProxy) ServeHTTP

func (p *SessionProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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