s3: fix v2 auth failing when path style addressing is off - #9893
Open
ubmids wants to merge 1 commit into
Open
Conversation
…one#8520 v2 signs the bucket as part of the canonical resource. With path style addressing it is already in the URL path, but with virtual host style it is in the Host header, so the signed resource was missing it and the server computed a different signature. Every request with --s3-v2-auth and --s3-force-path-style=false failed.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #8520.
I hit the same thing writing an S3-compatible store against a custom endpoint, and came looking to see how rclone handled it.
v2 signs the bucket as part of the canonical resource:
SignHTTPtakes that resource straight fromreq.URL.EscapedPath(). With path style the path is already/bucket/key, so it comes out right by accident. With virtual host style the bucket is in the Host header and the path is only/key, so it never reaches the string to sign and the server computes a different signature.That matches the report: dropping either
--s3-v2-author--s3-force-path-style=falsefixes it, because one puts the bucket back in the path and the other switches to v4, which signs Host anyway.This pulls the bucket back out of the Host. With an endpoint configured that is exact; without one it looks for the
s3label, since AWS hosts arebucket.s3.amazonaws.comorbucket.s3.<region>.amazonaws.com.There were no tests on the v2 signer, so I have added some. The one that matters asserts that the same bucket and key sign identically whether addressed path style or virtual host style, which is the invariant that was broken. Without the fix:
What I have not done is test against real AWS, since I do not have a bucket set up for v2 auth to point at. So this is verified against the spec and the unit tests, not end to end. @lewoberst if you are still around, it would be worth a run.
One thing I noticed and left alone:
SignHTTPignores itssigningTimeargument and usestime.Now(), which is why that test has a retry around the Date header. Happy to do it separately if you want it.make quicktestpasses other thancmd/gitannexandcmd/nfsmount, which fail the same way on a clean checkout here (norcloneon PATH, and mount permissions).