Skip to content

Commit

Permalink
docs: minor code documentation fixes to v2sig Verify (#2458)
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder authored Sep 9, 2021
1 parent a7b223c commit ac76250
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/gateway/sig/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,25 +222,26 @@ func buildPath(host string, bareDomain string, path string) string {
func (a *V2SigAuthenticator) Verify(creds *model.Credential, bareDomain string) error {
/*
s3 sigV2 implementation:
the s3 signature is somewhat different than general aws signature implementation.
the s3 signature is somewhat different from general aws signature implementation.
in boto3 configuration their value is 's3' and 's3v4' respectively, while the general aws signatures are
'v2' and 'v4'.
in 2020, the GO aws sdk does not inplement 's3' signature, So i will "translate" it from boto3.
in 2020, the GO aws sdk does not implement 's3' signature, So I will "translate" it from boto3.
source is class botocore.auth.HmacV1Auth
steps in building the string to be signed:
1. create initial string, with uppercase http method + '\n'
2. collect all required headers(in order):
- standard headers - 'content-md5', 'content-type', 'date' - if one of those does not appear, it is replaces with an
empty line '\n'. sorted and stringified
empty line '\n'. sorted and stringify
- custom headers - any header that starts with 'x-amz-'. if the header appears more than once - the values
are joined with ',' separator. sorted and stringified.
are joined with ',' separator. sorted and stringify.
- path of the object
- QSA(Query String Arguments) - query arguments are searched for "interesting Resources". */
- QSA(Query String Arguments) - query arguments are searched for "interesting Resources".
*/

/*
URI encoding requirements for aws signature are different from what GO does.
This logic is taken from https://docs.aws.amazon.com/AWSECommerceService/latest/DG/Query_QueryAuth.html
This replacements are necessary for Java. There is no description about GO, but I found the '=' needs treatment as well
These replacements are necessary for Java. There is no description about GO, but I found the '=' needs treatment as well
*/

patchedPath := strings.ReplaceAll(a.r.URL.Path, "=", "%3D")
Expand Down

0 comments on commit ac76250

Please sign in to comment.