mirror of https://github.com/minio/minio.git
fix(parseCredentialHeader): trim right Slash from credElements
This commit is contained in:
parent
b8631cf531
commit
6a28f28db4
|
@ -75,7 +75,7 @@ func parseCredentialHeader(credElement string, region string, stype serviceType)
|
|||
if creds[0] != "Credential" {
|
||||
return ch, ErrMissingCredTag
|
||||
}
|
||||
credElements := strings.Split(strings.TrimSpace(creds[1]), SlashSeparator)
|
||||
credElements := strings.Split(strings.TrimRight(strings.TrimSpace(creds[1]), SlashSeparator), SlashSeparator)
|
||||
if len(credElements) < 5 {
|
||||
return ch, ErrCredMalformed
|
||||
}
|
||||
|
|
|
@ -236,6 +236,25 @@ func TestParseCredentialHeader(t *testing.T) {
|
|||
"aws4_request"),
|
||||
expectedErrCode: ErrNone,
|
||||
},
|
||||
// Test Case - 12.
|
||||
// Test case with right inputs but trailing `/`. Expected to return a valid CredentialHeader.
|
||||
// "aws4_request" is the valid request version.
|
||||
{
|
||||
inputCredentialStr: generateCredentialStr(
|
||||
"Z7IXGOO6BZ0REAN1Q26I",
|
||||
sampleTimeStr,
|
||||
"us-west-1",
|
||||
"s3",
|
||||
"aws4_request/"),
|
||||
expectedCredentials: generateCredentials(
|
||||
t,
|
||||
"Z7IXGOO6BZ0REAN1Q26I",
|
||||
sampleTimeStr,
|
||||
"us-west-1",
|
||||
"s3",
|
||||
"aws4_request"),
|
||||
expectedErrCode: ErrNone,
|
||||
},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
|
|
Loading…
Reference in New Issue