Skip to content
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

Merged
merged 2 commits into from
Sep 19, 2016

Conversation

opalmer
Copy link
Contributor

@opalmer opalmer commented Sep 19, 2016

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.

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.
@opalmer opalmer self-assigned this Sep 19, 2016
@coveralls
Copy link

Coverage Status

Coverage remained the same at 10.568% when pulling 77aabc8 on fix_digest_method into 8534915 on master.

1 similar comment
@coveralls
Copy link

coveralls commented Sep 19, 2016

Coverage Status

Coverage remained the same at 10.568% when pulling 77aabc8 on fix_digest_method into 8534915 on master.

@opalmer
Copy link
Contributor Author

opalmer commented Sep 19, 2016

@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) {
Copy link
Owner

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 themethodhere. I thinkresponse.Request.Method` should work here.
See https://golang.org/pkg/net/http/#Response

What do you think?

Copy link
Contributor Author

@opalmer opalmer Sep 19, 2016

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.

@andygrunwald
Copy link
Owner

Thank you for debugging this. I made one small commit and like to get your feedback.
Otherwise, fine :) Feel free to merge it.

@coveralls
Copy link

coveralls commented Sep 19, 2016

Coverage Status

Coverage remained the same at 10.568% when pulling d595c54 on fix_digest_method into 8534915 on master.

@opalmer opalmer merged commit eba8c69 into master Sep 19, 2016
@opalmer opalmer deleted the fix_digest_method branch September 19, 2016 18:59
@opalmer opalmer modified the milestone: 0.1.0 Oct 8, 2016
@opalmer opalmer added the bug label Oct 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants