mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 00:03:29 +03:00
Canonicalize all the incoming input values, now PresignedPostPolicy works with minio-go
This commit is contained in:
@@ -323,18 +323,13 @@ func (api API) PostPolicyBucketHandler(w http.ResponseWriter, req *http.Request)
|
||||
}
|
||||
bucket := mux.Vars(req)["bucket"]
|
||||
formValues["Bucket"] = bucket
|
||||
object := formValues["key"]
|
||||
object := formValues["Key"]
|
||||
signature, perr := initPostPresignedPolicyV4(formValues)
|
||||
if perr != nil {
|
||||
errorIf(perr.Trace(), "Unable to initialize post policy presigned.", nil)
|
||||
writeErrorResponse(w, req, MalformedPOSTRequest, req.URL.Path)
|
||||
return
|
||||
}
|
||||
if perr = applyPolicy(formValues, signature.PresignedPolicy); perr != nil {
|
||||
errorIf(perr.Trace(), "Invalid request, policy doesn't match with the endpoint.", nil)
|
||||
writeErrorResponse(w, req, MalformedPOSTRequest, req.URL.Path)
|
||||
return
|
||||
}
|
||||
var ok bool
|
||||
if ok, perr = signature.DoesPolicySignatureMatch(formValues["X-Amz-Date"]); perr != nil {
|
||||
errorIf(perr.Trace(), "Unable to verify signature.", nil)
|
||||
@@ -345,6 +340,11 @@ func (api API) PostPolicyBucketHandler(w http.ResponseWriter, req *http.Request)
|
||||
writeErrorResponse(w, req, SignatureDoesNotMatch, req.URL.Path)
|
||||
return
|
||||
}
|
||||
if perr = applyPolicy(formValues); perr != nil {
|
||||
errorIf(perr.Trace(), "Invalid request, policy doesn't match with the endpoint.", nil)
|
||||
writeErrorResponse(w, req, MalformedPOSTRequest, req.URL.Path)
|
||||
return
|
||||
}
|
||||
metadata, perr := api.Donut.CreateObject(bucket, object, "", 0, fileBody, nil, nil)
|
||||
if perr != nil {
|
||||
errorIf(perr.Trace(), "CreateObject failed.", nil)
|
||||
|
||||
Reference in New Issue
Block a user