This repository has been archived by the owner on Dec 8, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Eliminate content length check in requestSignature #5
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Turns out the content length may not be defined for all POST requests, and may be 0 on the sending end and -1 on the receiving end, leading to signature mismatches. The new `TestSendAuthenticatedPostRequestToServer` reproduces the bug and validates its fix.
mbland
pushed a commit
to cloud-gov/oauth2_proxy
that referenced
this pull request
Oct 10, 2015
Using fakeNetConn in the test exposes a bug in 18F/hmacauth when handling POST requests, addressed by 18F/hmacauth#4. The bug was that the strings.Reader does not consume its buffer contents the same way that a net.Conn does. So the test would pass because its request body would still be intact after signing, but during live testing, the request body would be consumed by HmacAuth.requestSignature(). It also happened to expose a subsequent 18F/hmacauth bug addressed in 18F/hmacauth#5. It turns out that checking Request.ContentLength is an unreliable way of detecting that a body is present, and checking body != nil is sufficient. 18F/hmacauth#4 is already merged; when 18F/hmacauth#5 is in, I'll tag 18F/hmacauth v1.0.1 and update the Godeps to use that version, at which point the test should pass.
jcscottiii
added a commit
that referenced
this pull request
Oct 13, 2015
Eliminate content length check in requestSignature
mbland
pushed a commit
to cloud-gov/oauth2_proxy
that referenced
this pull request
Oct 13, 2015
v1.0.1 contains 18F/hmacauth#4 and 18F/hmacauth#5, needed to make TestRequestSignaturePostRequest pass again.
mbland
pushed a commit
to cloud-gov/oauth2_proxy
that referenced
this pull request
Nov 9, 2015
Using fakeNetConn in the test exposes a bug in 18F/hmacauth when handling POST requests, addressed by 18F/hmacauth#4. The bug was that the strings.Reader does not consume its buffer contents the same way that a net.Conn does. So the test would pass because its request body would still be intact after signing, but during live testing, the request body would be consumed by HmacAuth.requestSignature(). It also happened to expose a subsequent 18F/hmacauth bug addressed in 18F/hmacauth#5. It turns out that checking Request.ContentLength is an unreliable way of detecting that a body is present, and checking body != nil is sufficient. 18F/hmacauth#4 is already merged; when 18F/hmacauth#5 is in, I'll tag 18F/hmacauth v1.0.1 and update the Godeps to use that version, at which point the test should pass.
mbland
pushed a commit
to cloud-gov/oauth2_proxy
that referenced
this pull request
Nov 9, 2015
v1.0.1 contains 18F/hmacauth#4 and 18F/hmacauth#5, needed to make TestRequestSignaturePostRequest pass again.
mbland
pushed a commit
to cloud-gov/oauth2_proxy
that referenced
this pull request
Nov 9, 2015
Using fakeNetConn in the test exposes a bug in 18F/hmacauth when handling POST requests, addressed by 18F/hmacauth#4. The bug was that the strings.Reader does not consume its buffer contents the same way that a net.Conn does. So the test would pass because its request body would still be intact after signing, but during live testing, the request body would be consumed by HmacAuth.requestSignature(). It also happened to expose a subsequent 18F/hmacauth bug addressed in 18F/hmacauth#5. It turns out that checking Request.ContentLength is an unreliable way of detecting that a body is present, and checking body != nil is sufficient. 18F/hmacauth#4 is already merged; when 18F/hmacauth#5 is in, I'll tag 18F/hmacauth v1.0.1 and update the Godeps to use that version, at which point the test should pass.
mbland
pushed a commit
to cloud-gov/oauth2_proxy
that referenced
this pull request
Nov 9, 2015
v1.0.1 contains 18F/hmacauth#4 and 18F/hmacauth#5, needed to make TestRequestSignaturePostRequest pass again.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Turns out the content length may not be defined for all POST requests, and may
be 0 on the sending end and -1 on the receiving end, leading to signature
mismatches. The new
TestSendAuthenticatedPostRequestToServer
reproduces thebug and validates its fix.
cc: @jcscottiii