httpntlm

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: MIT Imports: 11 Imported by: 0

README

go-http-ntlm

go-http-ntlm is a Go package that contains NTLM transport (http.RoundTripper implementation) for http.Client to make NTLM auth protected http requests.

It is based on https://github.com/ThomsonReutersEikon/go-ntlm library.

Usage example

package main

import (
    "io/ioutil"
    "log"
    "net/http"
    "strings"

    "github.com/vadimi/go-http-ntlm"
)

func main() {

    // configure http client
    client := http.Client{
        Transport: &httpntlm.NtlmTransport{
            Domain:   "mydomain",
            User:     "testuser",
            Password: "fish",
        },
    }

    req, err := http.NewRequest("GET", "http://server/ntlm-auth-resource", strings.NewReader(""))
    resp, err := client.Do(req)

    if err != nil {
        log.Fatal(err)
    }

    defer func() {
        err := resp.Body.Close()
        if err != nil {
            log.Fatal(err)
        }
    }()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        log.Fatal(err)
    }

    log.Println(body)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NtlmTransport

type NtlmTransport struct {
	TLSClientConfig *tls.Config
	Domain          string
	User            string
	Password        string
}

NtlmTransport is implementation of http.RoundTripper interface

func (NtlmTransport) RoundTrip

func (t NtlmTransport) RoundTrip(req *http.Request) (res *http.Response, err error)

RoundTrip method send http request and tries to perform NTLM authentication

Jump to

Keyboard shortcuts

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