ntlm

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 12 Imported by: 10

README

go-ntlm-proxy-auth

GoDoc Circle CI

With this package, you can connect to http/https servers protected by an NTLM proxy in Golang.

This is a fork of https://github.com/Codehardt/go-ntlm-proxy-auth which adds support for HTTPS proxy URLs. It also uses the fork https://github.com/launchdarkly/go-ntlmssp instead of github.com/Azure/go-ntlmssp.

Example: NewNTLMProxyDialContext

// create a dialer
dialer := &net.Dialer{
    Timeout:   30 * time.Second,
    KeepAlive: 30 * time.Second,
}

// wrap dial context with NTLM
ntlmDialContext := ntlm.NewNTLMProxyDialContext(dialer, proxyURL, "user", "password", "domain", nil)

// create a http(s) client
client := &http.Client{
    Transport: &http.Transport{
        Proxy: nil, // !!! IMPORTANT, do not set proxy here !!!
        DialContext: ntlmDialContext,
    },
}

Example: WrapDialContext (deprecated - does not support HTTPS proxy URL)

// create a dialer
dialer := &net.Dialer{
    Timeout:   30 * time.Second,
    KeepAlive: 30 * time.Second,
}

// wrap dial context with NTLM
ntlmDialContext := ntlm.WrapDialContext(dialer.DialContext, "proxyAddr", "user", "password", "domain")

// create a http(s) client
client := &http.Client{
    Transport: &http.Transport{
        Proxy: nil, // !!! IMPORTANT, do not set proxy here !!!
        DialContext: ntlmDialContext,
    },
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDebugf

func SetDebugf(f func(format string, a ...interface{}))

SetDebugf sets a debugf function for debug output

Types

type DialContext

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

DialContext is the DialContext function that should be wrapped with a NTLM Authentication.

Example for DialContext:

dialContext := (&net.Dialer{KeepAlive: 30*time.Second, Timeout: 30*time.Second}).DialContext

func NewNTLMProxyDialContext

func NewNTLMProxyDialContext(dialer *net.Dialer, proxyURL url.URL, proxyUsername, proxyPassword, proxyDomain string, tlsConfig *tls.Config) DialContext

NewNTLMProxyDialContext provides a DialContext function that includes transparent NTLM proxy authentication. Unlike WrapDialContext, it describes the proxy location with a full URL, whose scheme can be HTTP or HTTPS.

func WrapDialContext

func WrapDialContext(dialContext DialContext, proxyAddress, proxyUsername, proxyPassword, proxyDomain string) DialContext

WrapDialContext wraps a DialContext with an NTLM Authentication to a proxy. Note that this does not support using HTTPS to connect to the proxy; use NewNTLMProxyDialContext if that is required.

Jump to

Keyboard shortcuts

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