From 17ebb94644c1909dd054fc94b58fa5e83bb6859d Mon Sep 17 00:00:00 2001 From: Pete Moore Date: Thu, 4 Aug 2016 20:29:05 +0200 Subject: [PATCH 1/4] Set a nonce in *Auth returned in func NewURLAuth(...) --- hawk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/hawk.go b/hawk.go index 07089d7..6e10143 100644 --- a/hawk.go +++ b/hawk.go @@ -294,6 +294,7 @@ func NewURLAuth(uri string, creds *Credentials, tsOffset time.Duration) (*Auth, Method: "GET", Credentials: *creds, Timestamp: Now().Add(tsOffset), + Nonce: nonce(), } if u.Path != "" { // url.Parse unescapes the path, which is unexpected From 18fd37eee162b92189177bdd29968c2254ddd7b1 Mon Sep 17 00:00:00 2001 From: Pete Moore Date: Fri, 5 Aug 2016 04:02:38 +0200 Subject: [PATCH 2/4] Revert "Set a nonce in *Auth returned in func NewURLAuth(...)" since nonce is not used in bewits. This reverts commit 17ebb94644c1909dd054fc94b58fa5e83bb6859d. --- hawk.go | 1 - 1 file changed, 1 deletion(-) diff --git a/hawk.go b/hawk.go index 6e10143..07089d7 100644 --- a/hawk.go +++ b/hawk.go @@ -294,7 +294,6 @@ func NewURLAuth(uri string, creds *Credentials, tsOffset time.Duration) (*Auth, Method: "GET", Credentials: *creds, Timestamp: Now().Add(tsOffset), - Nonce: nonce(), } if u.Path != "" { // url.Parse unescapes the path, which is unexpected From d3073d048f26babfe9c0b12c0e333ca71c13213a Mon Sep 17 00:00:00 2001 From: Jon Keys Date: Wed, 19 Oct 2016 11:50:30 -0400 Subject: [PATCH 3/4] remove explicit check of error message value for stale timestamp clock adjustment --- hawk.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hawk.go b/hawk.go index 07089d7..a17d9c0 100644 --- a/hawk.go +++ b/hawk.go @@ -663,7 +663,6 @@ func (auth *Auth) UpdateOffset(header string) (time.Duration, error) { var err error var ts time.Time var tsm []byte - var errMsg string for _, match := range matches { switch match[1] { @@ -678,15 +677,9 @@ func (auth *Auth) UpdateOffset(header string) (time.Duration, error) { if err != nil { return 0, AuthFormatError{"tsm", "malformed base64 encoding"} } - case "error": - errMsg = match[2] } } - if errMsg != "Stale timestamp" { - return 0, AuthFormatError{"error", "missing or unknown"} - } - if !hmac.Equal(tsm, auth.tsMac(strconv.FormatInt(ts.Unix(), 10))) { return 0, ErrInvalidMAC } From 9b2d64070e46a5243877291624f53a2348837f65 Mon Sep 17 00:00:00 2001 From: zaneli Date: Wed, 28 Nov 2018 11:30:48 +0900 Subject: [PATCH 4/4] Fix `NewURLAuth` func name in Godoc --- hawk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hawk.go b/hawk.go index a17d9c0..34a8ea7 100644 --- a/hawk.go +++ b/hawk.go @@ -283,7 +283,7 @@ func NewRequestAuth(req *http.Request, creds *Credentials, tsOffset time.Duratio return auth } -// NewRequestAuth builds a client Auth based on uri and creds. tsOffset will be +// NewURLAuth builds a client Auth based on uri and creds. tsOffset will be // applied to Now when setting the timestamp. func NewURLAuth(uri string, creds *Credentials, tsOffset time.Duration) (*Auth, error) { u, err := url.Parse(uri)