https://github.com/gregoryv/digest
Package digest implements Digest authorization
https://github.com/gregoryv/digest
auth authentication digest go golang
Last synced: 10 months ago
JSON representation
Package digest implements Digest authorization
- Host: GitHub
- URL: https://github.com/gregoryv/digest
- Owner: gregoryv
- License: mit
- Created: 2019-01-26T08:00:27.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-12-12T11:44:25.000Z (about 1 year ago)
- Last Synced: 2025-02-05T07:19:25.434Z (11 months ago)
- Topics: auth, authentication, digest, go, golang
- Language: Go
- Size: 24.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README

[digest](https://godoc.org/github.com/gregoryv/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)