digest

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

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 13 Imported by: 0

README

digest

Simple HTTP digest lib in Go (yes, yet another one blah blah)

usage

After importing the digest lib:

  headers.Set("WWW-Authenticate", digest.MakeDigestHeader(digest.AuthDigest("realm")))

And to check the result:

  auth := p.Headers.Get("Authorization")
  if len(auth) > 7 && auth[0:7] == "Digest " {
    info, err := digest.CheckDigestResponse(digest.ParsePairs(auth[7:]))
    // check err
    // check info.Username
    err = info.CheckPassword("GET", "good password")
    // check err again
    ...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthDigest

func AuthDigest(realm string) map[string]string

func AuthDigestHeader

func AuthDigestHeader(realm string) string

func MakeDigestHeader

func MakeDigestHeader(q map[string]string) string

func ParseList

func ParseList(value string) []string

ParseList parses a comma-separated list of values as described by RFC 2068 and returns list elements.

Lifted from https://code.google.com/p/gorilla/source/browse/http/parser/parser.go which was ported from urllib2.parse_http_list, from the Python standard library.

func ParsePairs

func ParsePairs(value string) map[string]string

ParsePairs extracts key/value pairs from a comma-separated list of values as described by RFC 2068 and returns a map[key]value. The resulting values are unquoted. If a list element doesn't contain a "=", the key is the element itself and the value is an empty string.

Lifted from https://code.google.com/p/gorilla/source/browse/http/parser/parser.go

Types

type Digest

type Digest struct {
	Username string
	Realm    string
	Nonce    []byte

	Response map[string]string
}

func CheckDigestResponse

func CheckDigestResponse(r map[string]string) (*Digest, error)

func ReadDigestAuthHeader

func ReadDigestAuthHeader(auth string) (*Digest, error)

func (*Digest) CheckPassword

func (d *Digest) CheckPassword(method, password string) error

Jump to

Keyboard shortcuts

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