From 1011d21416c6766145c0caed39a278f98eaef511 Mon Sep 17 00:00:00 2001 From: poornas Date: Sat, 16 Mar 2019 22:45:42 -0700 Subject: [PATCH] Fix credential parsing in signature v4 (#7377) Fixes #7376 --- cmd/signature-v4-parser.go | 2 +- cmd/signature-v4-parser_test.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/signature-v4-parser.go b/cmd/signature-v4-parser.go index dede3b38e..6bb1e518d 100644 --- a/cmd/signature-v4-parser.go +++ b/cmd/signature-v4-parser.go @@ -66,7 +66,7 @@ func getReqAccessKeyV4(r *http.Request, region string, stype serviceType) (auth. // parse credentialHeader string into its structured form. func parseCredentialHeader(credElement string, region string, stype serviceType) (ch credentialHeader, aec APIErrorCode) { - creds := strings.Split(strings.TrimSpace(credElement), "=") + creds := strings.SplitN(strings.TrimSpace(credElement), "=", 2) if len(creds) != 2 { return ch, ErrMissingFields } diff --git a/cmd/signature-v4-parser_test.go b/cmd/signature-v4-parser_test.go index 3baec0592..c0cae85c4 100644 --- a/cmd/signature-v4-parser_test.go +++ b/cmd/signature-v4-parser_test.go @@ -216,6 +216,25 @@ func TestParseCredentialHeader(t *testing.T) { "aws4_request"), expectedErrCode: ErrNone, }, + // Test Case - 11. + // Test case with right inputs -> AccessKey contains `=`. See minio/#7376 + // "aws4_request" is the valid request version. + { + inputCredentialStr: generateCredentialStr( + "LOCALKEY/DEV/1=", + sampleTimeStr, + "us-west-1", + "s3", + "aws4_request"), + expectedCredentials: generateCredentials( + t, + "LOCALKEY/DEV/1=", + sampleTimeStr, + "us-west-1", + "s3", + "aws4_request"), + expectedErrCode: ErrNone, + }, } for i, testCase := range testCases {