digest_auth_client

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: BSD-2-Clause Imports: 13 Imported by: 3

README

go-http-digest-auth-client

Golang Http Digest Authentication Client

This client implements RFC7616 HTTP Digest Access Authentication and by now the basic features should work.

Usage

Complete example from E2E test:


package main

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

	dac "github.com/Snawoot/go-http-digest-auth-client"
)

const (
	username = "test"
	password = "test123"
	uri      = "http://172.16.1.5"
)

func main() {
	client := &http.Client{
		Transport: dac.NewDigestTransport(username, password, http.DefaultTransport),
	}

	resp, err := client.Get(uri)
	if err != nil {
		log.Fatalln(err)
	}

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

	fmt.Printf(string(body))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AuthRetryNeeded = errors.New("retry request with authentication")
)

Functions

This section is empty.

Types

type DigestTransport added in v0.2.0

type DigestTransport struct {
	// contains filtered or unexported fields
}

func NewDigestTransport added in v1.0.0

func NewDigestTransport(username, password string, transport http.RoundTripper) *DigestTransport

NewRequest creates a new DigestTransport object

func (*DigestTransport) RoundTrip added in v0.2.0

func (dt *DigestTransport) RoundTrip(req *http.Request) (resp *http.Response, err error)

Execute initialise the request and get a response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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