-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A2 hash should use the request's method (closes #13) #14
Conversation
According to RFC2617 3.2.2.3 A2, 'If the "qop" directive's value is "auth" or is unspecified, then A2 is': A2 = Method ":" digest-uri-value Before this commit 'Method' was always GET even if the request was a POST, PUT, etc. For some reason, this bug has only posed a problem for SetReview. In other cases Gerrit seems to accept the request rather than returning 401 Unauthorized.
1 similar comment
@andygrunwald PTAL. Also, thanks @timou for the second set of eyes when debugging this! |
@@ -51,7 +51,7 @@ func (s *AuthenticationService) SetDigestAuth(username, password string) { | |||
// returns 401 Unauthorized and authType was set to authTypeDigest. The | |||
// resulting string is used to set the Authorization header before retrying | |||
// the request. | |||
func (s *AuthenticationService) digestAuthHeader(response *http.Response) (string, error) { | |||
func (s *AuthenticationService) digestAuthHeader(method string, response *http.Response) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The response
object contains the original request.
So you dont have to pass the
methodhere. I think
response.Request.Method` should work here.
See https://golang.org/pkg/net/http/#Response
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed and good point. We're already using response.Request
elsewhere in that same function too...not sure why I missed it.
Thank you for debugging this. I made one small commit and like to get your feedback. |
According to RFC2617 3.2.2.3 A2, 'If the "qop" directive's
value is "auth" or is unspecified, then A2 is':
Before this commit 'Method' was always GET even if
the request was a POST, PUT, etc.
For some reason, this bug has only posed a problem
for SetReview. In other cases Gerrit seems to accept
the request rather than returning 401 Unauthorized.