httpDigestAuth

package module
v0.0.0-...-b6c1066 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

http-digest-auth-client

Go (golang) http digest authentication client.

###This fork includes the following changes:

  • Changed MD5 hash generation to clean up some code
  • Added proper closing of request bodies (urgently needed for many requests in a row)
  • Removed fatal errors instead return with error (and log error text)

###Usage

import (
    "net/http"
    httpDigestAuth "github.com/pteich/http-digest-auth-client"
)
 
var DigestAuth *httpDigestAuth.DigestHeaders
 
func main() {

    httpClient := http.Client{}

    DigestAuth = &httpDigestAuth.DigestHeaders{}
    DigestAuth, err = DigestAuth.Auth("user","pass","url")
	
    req, err := http.NewRequest("GET", "url", body)	
	
    DigestAuth.ApplyAuth(req)

    resp, err := httpClient.Do(req)
}
 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DigestHeaders

type DigestHeaders struct {
	Realm     string
	Qop       string
	Method    string
	Nonce     string
	Opaque    string
	Algorithm string
	HA1       string
	HA2       string
	Cnonce    string
	Path      string
	Nc        int16
	Username  string
	Password  string
}

DigestHeaders tracks the state of authentication

func (*DigestHeaders) ApplyAuth

func (d *DigestHeaders) ApplyAuth(req *http.Request)

ApplyAuth adds proper auth header to the passed request

func (*DigestHeaders) Auth

func (d *DigestHeaders) Auth(username string, password string, uri string, client *http.Client) (*DigestHeaders, error)

Auth authenticates against a given URI

Jump to

Keyboard shortcuts

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