Skip to content
Package digest implements Digest authorization
Go Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmd/example
testdata
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
crypto.go
digest.go
digest_test.go
example_test.go
go.mod
go.sum
onchange.sh

README.md

Build Status codecov

digest - package provides header generator for digest authentication.

Quick start

go get -u github.com/gregoryv/digest

Example

The Auth object can be reused for subsequent requests thought it is not thread safe.

req, _ := http.NewRequest("GET", "/", nil)
resp, _ := http.DefaultClient.Do(req)
if resp.StatusCode == http.StatusUnauthorized {
    auth := NewAuth("john.doe", "secret")
    err := auth.Parse(resp.Header.Get("www-authenticate"))
    if err != nil {
        // cannot authenticate using this package
    }
    auth.Authorize(req)
}
resp, _ := http.DefaultClient.Do(req)

// and for the next request just authorize it before sending
auth.Authorize(req2)
You can’t perform that action at this time.