ntlmssp

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 14 Imported by: 1

README

go-ntlmssp

Golang package that provides NTLM/Negotiate authentication over HTTP

GoDoc Circle CI

This is a fork of github.com/Azure/go-ntlmssp, with minor changes for use in the LaunchDarkly Go SDK.

Protocol details from https://msdn.microsoft.com/en-us/library/cc236621.aspx Implementation hints from http://davenport.sourceforge.net/ntlm.html

This package only implements authentication, no key exchange or encryption. It only supports Unicode (UTF16LE) encoding of protocol strings, no OEM encoding. This package implements NTLMv2.

Usage

url, user, password := "http://www.example.com/secrets", "robpike", "pw123"
client := &http.Client{
  Transport: ntlmssp.Negotiator{
    RoundTripper:&http.Transport{},
  },
}

req, _ := http.NewRequest("GET", url, nil)
req.SetBasicAuth(user, password)
res, _ := client.Do(req)

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Documentation

Overview

Package ntlmssp provides NTLM/Negotiate authentication over HTTP

Protocol details from https://msdn.microsoft.com/en-us/library/cc236621.aspx, implementation hints from http://davenport.sourceforge.net/ntlm.html . This package only implements authentication, no key exchange or encryption. It only supports Unicode (UTF16LE) encoding of protocol strings, no OEM encoding. This package implements NTLMv2.

Index

Constants

This section is empty.

Variables

View Source
var DebugMode = true

Debugging flag

Functions

func DecodeFlags added in v1.0.2

func DecodeFlags(flags uint32) string

DecodeFlags returns a formatted string listing NTLM flag names

func DecodeNTLMMessage added in v1.0.2

func DecodeNTLMMessage(blob []byte)

DecodeNTLMMessage decodes NTLM messages and prints details

func DecodeType1Message added in v1.0.2

func DecodeType1Message(blob []byte)

DecodeType1Message prints details of an NTLM Type 1 message

func DecodeType2Message added in v1.0.2

func DecodeType2Message(blob []byte)

DecodeType2Message prints details of an NTLM Type 2 message

func DecodeType3Message added in v1.0.2

func DecodeType3Message(blob []byte)

DecodeType3Message prints details of an NTLM Type 3 message

func GetDomain

func GetDomain(user string) (string, string)

GetDomain : parse domain name from based on slashes in the input

func NewNegotiateMessage

func NewNegotiateMessage(domainName, workstationName string) ([]byte, error)

NewNegotiateMessage creates a new NEGOTIATE message with the flags that this package supports.

func PrintDebug added in v1.0.2

func PrintDebug(format string, args ...interface{})

PrintDebug logs debug messages when DebugMode is enabled

func ProcessChallenge

func ProcessChallenge(challengeMessageData []byte, user, password string) ([]byte, error)

ProcessChallenge crafts an AUTHENTICATE message in response to the CHALLENGE message that was received from the server

Types

type Negotiator

type Negotiator struct{ http.RoundTripper }

Negotiator is a http.Roundtripper decorator that automatically converts basic authentication to NTLM/Negotiate authentication when appropriate.

func (Negotiator) RoundTrip

func (l Negotiator) RoundTrip(req *http.Request) (res *http.Response, err error)

RoundTrip sends the request to the server, handling any authentication re-sends as needed.

type Version

type Version struct {
	ProductMajorVersion uint8
	ProductMinorVersion uint8
	ProductBuild        uint16

	NTLMRevisionCurrent uint8
	// contains filtered or unexported fields
}

Version is a struct representing https://msdn.microsoft.com/en-us/library/cc236654.aspx

func DefaultVersion

func DefaultVersion() Version

DefaultVersion returns a Version with "sensible" defaults (Windows 7)

Jump to

Keyboard shortcuts

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