@ -2599,7 +2599,7 @@ func (api objectAPIHandlers) PutObjectLegalHoldHandler(w http.ResponseWriter, r
}
// Check permissions to perform this legal hold operation
if s3Err := isPutActionAllowed ( get RequestAuthType( r ) , bucke t, object , r , policy . PutObjectLegalHoldAction ) ; s3Err != ErrNone {
if s3Err := check RequestAuthType( c tx , r , policy . PutObjectLegalHoldAction , bucket , object ) ; s3Err != ErrNone {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -2608,11 +2608,8 @@ func (api objectAPIHandlers) PutObjectLegalHoldHandler(w http.ResponseWriter, r
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Get Content-Md5 sent by client and verify if valid
md5Bytes , err := checkValidMD5 ( r . Header )
if err != nil {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrInvalidDigest ) , r . URL , guessIsBrowserReq ( r ) )
if ! hasContentMD5 ( r . Header ) {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrMissingContentMD5 ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -2627,18 +2624,6 @@ func (api objectAPIHandlers) PutObjectLegalHoldHandler(w http.ResponseWriter, r
return
}
// verify Content-MD5 sum of request body if this header set
if len ( md5Bytes ) > 0 {
data , err := xml . Marshal ( legalHold )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if hex . EncodeToString ( md5Bytes ) != getMD5Hash ( data ) {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrInvalidDigest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
getObjectInfo := objectAPI . GetObjectInfo
if api . CacheAPI ( ) != nil {
getObjectInfo = api . CacheAPI ( ) . GetObjectInfo
@ -2769,7 +2754,7 @@ func (api objectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r
return
}
// Check permissions to perform this governance operation
if s3Err := isPutActionAllowed ( get RequestAuthType( r ) , bucke t, object , r , policy . PutObjectRetentionAction ) ; s3Err != ErrNone {
if s3Err := check RequestAuthType( c tx , r , policy . PutObjectRetentionAction , bucket , object ) ; s3Err != ErrNone {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -2778,11 +2763,8 @@ func (api objectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// Get Content-Md5 sent by client and verify if valid
md5Bytes , err := checkValidMD5 ( r . Header )
if err != nil {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrInvalidDigest ) , r . URL , guessIsBrowserReq ( r ) )
if ! hasContentMD5 ( r . Header ) {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrMissingContentMD5 ) , r . URL , guessIsBrowserReq ( r ) )
return
}
@ -2809,18 +2791,7 @@ func (api objectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( s3Err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
// verify Content-MD5 sum of request body if this header set
if len ( md5Bytes ) > 0 {
data , err := xml . Marshal ( objRetention )
if err != nil {
writeErrorResponse ( ctx , w , toAPIError ( ctx , err ) , r . URL , guessIsBrowserReq ( r ) )
return
}
if hex . EncodeToString ( md5Bytes ) != getMD5Hash ( data ) {
writeErrorResponse ( ctx , w , errorCodes . ToAPIErr ( ErrInvalidDigest ) , r . URL , guessIsBrowserReq ( r ) )
return
}
}
objInfo . UserDefined [ strings . ToLower ( xhttp . AmzObjectLockMode ) ] = string ( objRetention . Mode )
objInfo . UserDefined [ strings . ToLower ( xhttp . AmzObjectLockRetainUntilDate ) ] = objRetention . RetainUntilDate . UTC ( ) . Format ( time . RFC3339 )
objInfo . metadataOnly = true