mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
handle post policy only if it is set. (#6852)
Previously policy in post form is assumed to be set always. This is fixed by doing the check when policy is set.
This commit is contained in:
parent
d6af3c1237
commit
18ced1102c
@ -572,31 +572,34 @@ func (api objectAPIHandlers) PostPolicyBucketHandler(w http.ResponseWriter, r *h
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
postPolicyForm, err := parsePostPolicyForm(string(policyBytes))
|
// Handle policy if it is set.
|
||||||
if err != nil {
|
if len(policyBytes) > 0 {
|
||||||
writeErrorResponse(w, ErrMalformedPOSTRequest, r.URL, guessIsBrowserReq(r))
|
postPolicyForm, err := parsePostPolicyForm(string(policyBytes))
|
||||||
return
|
if err != nil {
|
||||||
}
|
writeErrorResponse(w, ErrMalformedPOSTRequest, r.URL, guessIsBrowserReq(r))
|
||||||
|
|
||||||
// Make sure formValues adhere to policy restrictions.
|
|
||||||
if apiErr = checkPostPolicy(formValues, postPolicyForm); apiErr != ErrNone {
|
|
||||||
writeErrorResponse(w, apiErr, r.URL, guessIsBrowserReq(r))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that the object size is within expected range, also the file size
|
|
||||||
// should not exceed the maximum single Put size (5 GiB)
|
|
||||||
lengthRange := postPolicyForm.Conditions.ContentLengthRange
|
|
||||||
if lengthRange.Valid {
|
|
||||||
if fileSize < lengthRange.Min {
|
|
||||||
writeErrorResponse(w, toAPIErrorCode(ctx, errDataTooSmall), r.URL, guessIsBrowserReq(r))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if fileSize > lengthRange.Max || isMaxObjectSize(fileSize) {
|
// Make sure formValues adhere to policy restrictions.
|
||||||
writeErrorResponse(w, toAPIErrorCode(ctx, errDataTooLarge), r.URL, guessIsBrowserReq(r))
|
if apiErr = checkPostPolicy(formValues, postPolicyForm); apiErr != ErrNone {
|
||||||
|
writeErrorResponse(w, apiErr, r.URL, guessIsBrowserReq(r))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that the object size is within expected range, also the file size
|
||||||
|
// should not exceed the maximum single Put size (5 GiB)
|
||||||
|
lengthRange := postPolicyForm.Conditions.ContentLengthRange
|
||||||
|
if lengthRange.Valid {
|
||||||
|
if fileSize < lengthRange.Min {
|
||||||
|
writeErrorResponse(w, toAPIErrorCode(ctx, errDataTooSmall), r.URL, guessIsBrowserReq(r))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if fileSize > lengthRange.Max || isMaxObjectSize(fileSize) {
|
||||||
|
writeErrorResponse(w, toAPIErrorCode(ctx, errDataTooLarge), r.URL, guessIsBrowserReq(r))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract metadata to be saved from received Form.
|
// Extract metadata to be saved from received Form.
|
||||||
|
Loading…
Reference in New Issue
Block a user