mirror of
https://github.com/minio/minio.git
synced 2025-02-22 11:02:30 -05:00
* Checking allowance on empty prefix or Snowball-prefix - fixes #20883 * Check the policy for each object during Snowball auto-extraction
This commit is contained in:
parent
4355ea3c3f
commit
60f8423157
@ -2231,8 +2231,15 @@ func (api objectAPIHandlers) PutObjectExtractHandler(w http.ResponseWriter, r *h
|
|||||||
putObject = objectAPI.PutObject
|
putObject = objectAPI.PutObject
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check if put is allowed
|
var opts untarOptions
|
||||||
if s3Err = isPutActionAllowed(ctx, rAuthType, bucket, object, r, policy.PutObjectAction); s3Err != ErrNone {
|
opts.ignoreDirs = strings.EqualFold(r.Header.Get(xhttp.MinIOSnowballIgnoreDirs), "true")
|
||||||
|
opts.ignoreErrs = strings.EqualFold(r.Header.Get(xhttp.MinIOSnowballIgnoreErrors), "true")
|
||||||
|
opts.prefixAll = r.Header.Get(xhttp.MinIOSnowballPrefix)
|
||||||
|
if opts.prefixAll != "" {
|
||||||
|
opts.prefixAll = trimLeadingSlash(pathJoin(opts.prefixAll, slashSeparator))
|
||||||
|
}
|
||||||
|
// Check if put is allow for specified prefix.
|
||||||
|
if s3Err = isPutActionAllowed(ctx, rAuthType, bucket, opts.prefixAll, r, policy.PutObjectAction); s3Err != ErrNone {
|
||||||
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2300,7 +2307,10 @@ func (api objectAPIHandlers) PutObjectExtractHandler(w http.ResponseWriter, r *h
|
|||||||
|
|
||||||
putObjectTar := func(reader io.Reader, info os.FileInfo, object string) error {
|
putObjectTar := func(reader io.Reader, info os.FileInfo, object string) error {
|
||||||
size := info.Size()
|
size := info.Size()
|
||||||
|
if s3Err = isPutActionAllowed(ctx, getRequestAuthType(r), bucket, object, r, policy.PutObjectAction); s3Err != ErrNone {
|
||||||
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Err), r.URL)
|
||||||
|
return errors.New(errorCodes.ToAPIErr(s3Err).Code)
|
||||||
|
}
|
||||||
metadata := map[string]string{
|
metadata := map[string]string{
|
||||||
xhttp.AmzStorageClass: sc, // save same storage-class as incoming stream.
|
xhttp.AmzStorageClass: sc, // save same storage-class as incoming stream.
|
||||||
}
|
}
|
||||||
@ -2336,7 +2346,7 @@ func (api objectAPIHandlers) PutObjectExtractHandler(w http.ResponseWriter, r *h
|
|||||||
|
|
||||||
if r.Header.Get(xhttp.AmzBucketReplicationStatus) == replication.Replica.String() {
|
if r.Header.Get(xhttp.AmzBucketReplicationStatus) == replication.Replica.String() {
|
||||||
if s3Err = isPutActionAllowed(ctx, getRequestAuthType(r), bucket, object, r, policy.ReplicateObjectAction); s3Err != ErrNone {
|
if s3Err = isPutActionAllowed(ctx, getRequestAuthType(r), bucket, object, r, policy.ReplicateObjectAction); s3Err != ErrNone {
|
||||||
return err
|
return errors.New(errorCodes.ToAPIErr(s3Err).Code)
|
||||||
}
|
}
|
||||||
metadata[ReservedMetadataPrefixLower+ReplicaStatus] = replication.Replica.String()
|
metadata[ReservedMetadataPrefixLower+ReplicaStatus] = replication.Replica.String()
|
||||||
metadata[ReservedMetadataPrefixLower+ReplicaTimestamp] = UTCNow().Format(time.RFC3339Nano)
|
metadata[ReservedMetadataPrefixLower+ReplicaTimestamp] = UTCNow().Format(time.RFC3339Nano)
|
||||||
@ -2483,14 +2493,6 @@ func (api objectAPIHandlers) PutObjectExtractHandler(w http.ResponseWriter, r *h
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts untarOptions
|
|
||||||
opts.ignoreDirs = strings.EqualFold(r.Header.Get(xhttp.MinIOSnowballIgnoreDirs), "true")
|
|
||||||
opts.ignoreErrs = strings.EqualFold(r.Header.Get(xhttp.MinIOSnowballIgnoreErrors), "true")
|
|
||||||
opts.prefixAll = r.Header.Get(xhttp.MinIOSnowballPrefix)
|
|
||||||
if opts.prefixAll != "" {
|
|
||||||
opts.prefixAll = trimLeadingSlash(pathJoin(opts.prefixAll, slashSeparator))
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = untar(ctx, hreader, putObjectTar, opts); err != nil {
|
if err = untar(ctx, hreader, putObjectTar, opts); err != nil {
|
||||||
apiErr := errorCodes.ToAPIErr(s3Err)
|
apiErr := errorCodes.ToAPIErr(s3Err)
|
||||||
// If not set, convert or use BadRequest
|
// If not set, convert or use BadRequest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user