Validate object lock when setting replication config. (#10200)

Check if object lock is enabled on
destination bucket while setting replication
configuration on a object lock enabled bucket.
This commit is contained in:
poornas
2020-08-04 23:02:27 -07:00
committed by GitHub
parent 1cdaced8b6
commit 88daaef76b
3 changed files with 23 additions and 0 deletions

View File

@@ -56,6 +56,14 @@ func validateReplicationDestination(ctx context.Context, bucket string, rCfg *re
if found, _ := clnt.BucketExists(ctx, rCfg.GetDestination().Bucket); !found {
return false, BucketReplicationDestinationNotFound{Bucket: rCfg.GetDestination().Bucket}
}
if ret, err := globalBucketObjectLockSys.Get(bucket); err == nil {
if ret.LockEnabled {
lock, _, _, _, err := clnt.GetObjectLockConfig(ctx, rCfg.GetDestination().Bucket)
if err != nil || lock != "Enabled" {
return false, BucketReplicationDestinationMissingLock{Bucket: rCfg.GetDestination().Bucket}
}
}
}
// validate replication ARN against target endpoint
c, ok := globalBucketTargetSys.arnRemotesMap[rCfg.ReplicationArn]
if ok {