Documentation
¶
Overview ¶
Package safehttp provides outbound HTTP clients for URLs selected by remote servers. It prevents public endpoints from pivoting requests into local or private networks while preserving explicitly configured local development.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy binds remotely selected restricted destinations to an explicitly configured URL. Public destinations remain available in every policy.
func NewPolicy ¶
NewPolicy constructs a destination policy from an operator-selected URL. The selected hostname may resolve into a private network, but that permission does not extend to server-discovered hostnames. Explicit localhost opts into loopback; another restricted IP opts into that exact address only.
func (*Policy) Client ¶
Client returns an HTTP client whose redirects and connections are checked by the policy. Environment proxies are intentionally disabled because a proxy would resolve the final destination outside this process's validated dial.
type RedirectMode ¶
type RedirectMode uint8
RedirectMode controls whether a client may follow redirects to a new origin.
const ( // PublicRedirects permits redirects whose destinations satisfy the policy. PublicRedirects RedirectMode = iota // SameOriginRedirects additionally requires every redirect to retain the // original request's scheme, host, and effective port. SameOriginRedirects )