Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNilTransport = errors.New("transport is nil") ErrBadChallenge = errors.New("challenge is bad") ErrAlgNotImplemented = errors.New("alg not implemented") ErrQopNotSupported = errors.New("qop not supported") // The Algs supported by this digester Algs = map[string]func() hash.Hash{ "": md5.New, "MD5": md5.New, "SHA-256": sha256.New, "SHA-512": sha512.New, "SHA-512-256": sha512.New512_256, } QopFirst = func(qops []string) string { for _, qop := range qops { return qop } return "" } Cnoncer16 = func() (string, error) { b := make([]byte, 16) _, err := io.ReadFull(rand.Reader, b) return hex.EncodeToString(b), err } )
Functions ¶
Types ¶
type Challenge ¶
type Challenge struct { Scheme string Realm string Domain string Nonce string Opaque string Stale string Algorithm string Qop []string Charset string Userhash string }
Challenge is the digest response www-authenticate header parsed (rfc 7616)
func NewChallenge ¶
NewChallenge parses the www-authenticate header
type Credentials ¶
type Credentials struct { // our creds Username string Password string // from the challenge Realm string Nonce string NonceCount int // times we've responded to this nonce Opaque string Qop string // the chosen auth from the server list Algorithm string // <alg>-sess implies session-keying () // session-keying CnoncePrime string NoncePrime string // per response Method string URI string Body string // used for auth-int Cnonce string }
Credentials holds the per request response params
func (*Credentials) Authorization ¶
func (c *Credentials) Authorization() (string, error)
func (*Credentials) Hasher ¶
func (c *Credentials) Hasher() Hasher
type Transport ¶
type Transport struct { Username string Password string Transport http.RoundTripper // NoncePrime is for session keying 'MD5-sess' NoncePrime string // CnoncePrime is for session keying 'MD5-sess' CnoncePrime string // NonCounter tracks the count of all nonces we've sent a request for NonceCounter map[string]int // QopPref provides a seem for qop selection QopPref QopPref // Cnoncer provides a seem for cnonce generation Cnoncer Cnoncer // contains filtered or unexported fields }
Transport is an implementation of http.RoundTripper that takes care of http digest authentication.
func NewTransport ¶
func NewTransport(username, password string, transport http.RoundTripper) *Transport
NewTransport creates a new digest transport using the http.DefaultTransport.
func (*Transport) NewCredentials ¶
func (t *Transport) NewCredentials(method, uri, body, cnonce string, c *Challenge) *Credentials
NewCredentials ...
func (*Transport) NewHTTPClient ¶
NewHTTPClient returns an HTTP client that uses the digest transport.
Click to show internal directories.
Click to hide internal directories.