package sso import ( "context" "net" "net/http" "time" "git.zb-server.de/ZB-Server/uptimesebi/internal/netguard" ) // ErrForbiddenAddress is returned when an IdP resolves to an address the // client may not contact. var ErrForbiddenAddress = netguard.ErrForbiddenAddress // SafeHTTPClient returns a client for talking to customer-configured IdPs. // Unless allowPrivate is set it refuses to connect to non-public addresses. func SafeHTTPClient(allowPrivate bool) *http.Client { d := netguard.Dialer(allowPrivate, 5*time.Second) tr := http.DefaultTransport.(*http.Transport).Clone() tr.Proxy = nil tr.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) { return d.DialContext(ctx, network, addr) } return &http.Client{Transport: tr, Timeout: 10 * time.Second} }