netguard

package
v0.99.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package netguard is the single outbound-network policy for AuthKit: the private/reserved address list, the resolve-then-dial SSRF guard, and the timeout-bounded HTTP client every package uses for fetches it does not fully control (JWKS, application documents, IdP endpoints).

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

DefaultTimeout bounds AuthKit's outbound HTTP calls. A slow or hostile endpoint must never wedge a request goroutine, and single-flighted fetches (JWKS) would otherwise stall every concurrent waiter.

Variables

This section is empty.

Functions

func Client

func Client(timeout time.Duration, allowPrivate bool) *http.Client

Client returns a timeout-bounded *http.Client over Transport(allowPrivate). timeout <= 0 uses DefaultTimeout.

func IsInternalHostname

func IsInternalHostname(host string) bool

IsInternalHostname reports whether host names a well-known internal target (localhost, cloud metadata aliases, Docker/Podman host-access names). It is a syntactic check for registration-time validation; the dialer's post-resolution IP check is the layer that catches everything else.

func IsPrivateIP

func IsPrivateIP(ip net.IP) bool

IsPrivateIP reports whether ip is loopback, link-local, multicast, unspecified, or inside PrivateBlocks.

func Transport

func Transport(allowPrivate bool) *http.Transport

Transport returns an http.Transport wired to DialerWith(net.DefaultResolver, allowPrivate) with bounded handshake and header timeouts. A guarded transport never uses an egress proxy: the proxy would be dialed in place of the resolved target and the private-address check would no longer see the real destination.

func TransportWith

func TransportWith(r Resolver, allowPrivate bool) *http.Transport

TransportWith is Transport with an explicit Resolver.

Types

type DialFunc

type DialFunc = func(ctx context.Context, network, addr string) (net.Conn, error)

DialFunc is the http.Transport.DialContext shape.

func DialerWith

func DialerWith(r Resolver, allowPrivate bool) DialFunc

DialerWith is Dialer with an explicit Resolver.

type Resolver

type Resolver interface {
	LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
}

Resolver is the DNS seam the guarded dialer resolves through. *net.Resolver satisfies it.

Jump to

Keyboard shortcuts

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