api: postPolicy cleanup. Simplify the code and re-use. (#3890)

This change is cleanup of the postPolicyHandler code
primarily to address the flow and also converting
certain critical parts into self contained functions.
This commit is contained in:
Harshavardhana
2017-03-13 14:41:13 -07:00
committed by GitHub
parent 3314501f19
commit 5f7565762e
12 changed files with 222 additions and 162 deletions

View File

@@ -64,14 +64,14 @@ var resourceList = []string{
"website",
}
func doesPolicySignatureV2Match(formValues map[string]string) APIErrorCode {
func doesPolicySignatureV2Match(formValues http.Header) APIErrorCode {
cred := serverConfig.GetCredential()
accessKey := formValues["Awsaccesskeyid"]
accessKey := formValues.Get("AWSAccessKeyId")
if accessKey != cred.AccessKey {
return ErrInvalidAccessKeyID
}
signature := formValues["Signature"]
policy := formValues["Policy"]
policy := formValues.Get("Policy")
signature := formValues.Get("Signature")
if signature != calculateSignatureV2(policy, cred.SecretKey) {
return ErrSignatureDoesNotMatch
}