forked from TrueCloudLab/frostfs-s3-gw
[#354] Check container owner if bucket exists
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
fdc07b8dc1
commit
f04815c32f
1 changed files with 5 additions and 1 deletions
|
@ -643,7 +643,7 @@ func (n *layer) DeleteObjects(ctx context.Context, bucket string, objects []*Ver
|
|||
}
|
||||
|
||||
func (n *layer) CreateBucket(ctx context.Context, p *CreateBucketParams) (*cid.ID, error) {
|
||||
_, err := n.GetBucketInfo(ctx, p.Name)
|
||||
bktInfo, err := n.GetBucketInfo(ctx, p.Name)
|
||||
if err != nil {
|
||||
if errors.IsS3Error(err, errors.ErrNoSuchBucket) {
|
||||
return n.createContainer(ctx, p)
|
||||
|
@ -651,6 +651,10 @@ func (n *layer) CreateBucket(ctx context.Context, p *CreateBucketParams) (*cid.I
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if p.SessionToken != nil && bktInfo.Owner.Equal(p.SessionToken.OwnerID()) {
|
||||
return nil, errors.GetAPIError(errors.ErrBucketAlreadyOwnedByYou)
|
||||
}
|
||||
|
||||
return nil, errors.GetAPIError(errors.ErrBucketAlreadyExists)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue