PresignedPost: Support for Signature V2 presigned POST Policy. (#3043)

fixes #2993
This commit is contained in:
Krishna Srinivas
2016-10-22 21:27:12 +05:30
committed by Harshavardhana
parent 4b5b363c6c
commit e51be73ac7
5 changed files with 166 additions and 24 deletions

View File

@@ -145,10 +145,19 @@ func getSignature(signingKey []byte, stringToSign string) string {
return hex.EncodeToString(sumHMAC(signingKey, []byte(stringToSign)))
}
// Check to see if Policy is signed correctly.
func doesPolicySignatureMatch(formValues map[string]string) APIErrorCode {
// For SignV2 - Signature field will be valid
if formValues["Signature"] != "" {
return doesPolicySignatureV2Match(formValues)
}
return doesPolicySignatureV4Match(formValues)
}
// doesPolicySignatureMatch - Verify query headers with post policy
// - http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-HTTPPOSTConstructPolicy.html
// returns ErrNone if the signature matches.
func doesPolicySignatureMatch(formValues map[string]string) APIErrorCode {
func doesPolicySignatureV4Match(formValues map[string]string) APIErrorCode {
// Access credentials.
cred := serverConfig.GetCredential()