Skip to content

Commit

Permalink
Default qop to "auth" in HTTPDigestAuth(#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Aug 18, 2023
1 parent 13d91d2 commit 66c121d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ import (
"crypto/sha512"
"errors"
"fmt"
"github.com/imroc/req/v3/internal/header"
"hash"
"io"
"net/http"
"strings"

"github.com/imroc/req/v3/internal/header"
)

var (
errDigestBadChallenge = errors.New("digest: challenge is bad")
errDigestCharset = errors.New("digest: unsupported charset")
errDigestAlgNotSupported = errors.New("digest: algorithm is not supported")
errDigestQopNotSupported = errors.New("digest: no supported qop in list")
errDigestNoQop = errors.New("digest: qop must be specified")
)

var hashFuncs = map[string]func() hash.Hash{
Expand Down Expand Up @@ -213,7 +213,7 @@ func (c *credentials) authorize() (string, error) {
func (c *credentials) validateQop() error {
// Currently only supporting auth quality of protection. TODO: add auth-int support
if c.messageQop == "" {
return errDigestNoQop
c.messageQop = "auth"
}
possibleQops := strings.Split(c.messageQop, ", ")
var authSupport bool
Expand All @@ -227,8 +227,6 @@ func (c *credentials) validateQop() error {
return errDigestQopNotSupported
}

c.messageQop = "auth"

return nil
}

Expand Down

0 comments on commit 66c121d

Please sign in to comment.