Documentation
¶
Overview ¶
The httpdigest package provides an implementation of http.RoundTripper that resolves a HTTP Digest Authentication (https://tools.ietf.org/html/rfc2617). At the moment, this only implements the MD5 and "auth" portions of the RFC. This package was created initially to cover a monero-wallet-rpc call using digest authentication.
Example (monero-wallet-rpc with digest):
package main
import (
//"net/http"
"fmt"
"github.com/gabstv/go-monero/walletrpc"
"github.com/gabstv/httpdigest"
)
func main() {
t := httpdigest.New("john", "doe")
// to do a normal http request:
//
// cl := &http.Client{
// Transport: t,
// }
// req, _ := http.NewRequest(http.MethodGet, "url", nil)
// resp, err := cl.Do(req)
client := walletrpc.New(walletrpc.Config{
Address: "http://127.0.0.1:29567/json_rpc",
Transport: t,
})
balance, unlocked, err := client.Getbalance()
if err != nil {
panic(err)
}
fmt.Println("balance", walletrpc.XMRToDecimal(balance))
fmt.Println("unlocked balance", walletrpc.XMRToDecimal(unlocked))
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Debug bool
Functions ¶
This section is empty.
Types ¶
type DigestInput ¶
type DigestInput struct {
Username string
Password string
DigestURI string
// nonce-count
// The nc-value is the hexadecimal
// count of the number of requests (including the current request)
// that the client has sent with the nonce value in this request. For
// example, in the first request sent in response to a given nonce
// value, the client sends "nc=00000001". The purpose of this
// directive is to allow the server to detect request replays by
// maintaining its own copy of this count - if the same nc-value is
// seen twice, then the request is a replay.
NonceCount uint
Cnonce string
Method string
}
type Transport ¶
type Transport struct {
Username string
Password string
Transport http.RoundTripper
// Generator function for cnonce. If not specified, the transport will
// generate one automatically.
CnonceGen func() string
}
Transport is an implementation of http.RoundTripper that can handle http digest authentication.
func New ¶
NewTransport creates a new digest transport using the http.DefaultTransport. You may change the underlying transport if needed (i.e: handling self-signed certificates).
Click to show internal directories.
Click to hide internal directories.