Skip to content

Authorize to an NTLM Proxy for a HTTP(S) connection in Golang (LaunchDarkly fork)

License

Notifications You must be signed in to change notification settings

launchdarkly/go-ntlm-proxy-auth

 
 

Repository files navigation

go-ntlm-proxy-auth

License: MIT GoDoc Build and Test

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,
    },
}