diff --git a/auth/bucket_policy_actions.go b/auth/bucket_policy_actions.go index ec0b763..a50d4a4 100644 --- a/auth/bucket_policy_actions.go +++ b/auth/bucket_policy_actions.go @@ -70,6 +70,8 @@ const ( GetInventoryConfigurationAction Action = "s3:GetInventoryConfiguration" PutLifecycleConfigurationAction Action = "s3:PutLifecycleConfiguration" GetLifecycleConfigurationAction Action = "s3:GetLifecycleConfiguration" + PutBucketLoggingAction Action = "s3:PutBucketLogging" + GetBucketLoggingAction Action = "s3:GetBucketLogging" AllActions Action = "s3:*" ) diff --git a/metrics/actions.go b/metrics/actions.go index 579767c..971100d 100644 --- a/metrics/actions.go +++ b/metrics/actions.go @@ -93,6 +93,8 @@ var ( ActionPutBucketLifecycleConfiguration = "s3_PutBucketLifecycleConfiguration" ActionGetBucketLifecycleConfiguration = "s3_GetBucketLifecycleConfiguration" ActionDeleteBucketLifecycle = "s3_DeleteBucketLifecycle" + ActionPutBucketLogging = "s3_PutBucketLogging" + ActionGetBucketLogging = "s3_GetBucketLogging" // Admin actions ActionAdminCreateUser = "admin_CreateUser" diff --git a/s3api/router.go b/s3api/router.go index 967f225..c2e4f51 100644 --- a/s3api/router.go +++ b/s3api/router.go @@ -265,6 +265,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ middlewares.ParseAcl(be), ), ) + bucketRouter.Put("", + middlewares.MatchQueryArgs("logging"), + controllers.ProcessHandlers( + ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)), + metrics.ActionPutBucketLogging, + services, + middlewares.BucketObjectNameValidator(), + middlewares.AuthorizePublicBucketAccess(be, metrics.ActionPutBucketLogging, auth.PutBucketLoggingAction, auth.PermissionWrite), + middlewares.VerifyPresignedV4Signature(root, iam, region, debug), + middlewares.VerifyV4Signature(root, iam, region, debug), + middlewares.VerifyMD5Body(), + middlewares.ParseAcl(be), + ), + ) bucketRouter.Put("", controllers.ProcessHandlers( ctrl.CreateBucket, @@ -657,6 +671,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ middlewares.ParseAcl(be), ), ) + bucketRouter.Get("", + middlewares.MatchQueryArgs("logging"), + controllers.ProcessHandlers( + ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)), + metrics.ActionGetBucketLogging, + services, + middlewares.BucketObjectNameValidator(), + middlewares.AuthorizePublicBucketAccess(be, metrics.ActionGetBucketLogging, auth.GetBucketLoggingAction, auth.PermissionRead), + middlewares.VerifyPresignedV4Signature(root, iam, region, debug), + middlewares.VerifyV4Signature(root, iam, region, debug), + middlewares.VerifyMD5Body(), + middlewares.ParseAcl(be), + ), + ) bucketRouter.Get("", middlewares.MatchQueryArgWithValue("list-type", "2"), controllers.ProcessHandlers( diff --git a/tests/integration/group-tests.go b/tests/integration/group-tests.go index ae0f79c..209b630 100644 --- a/tests/integration/group-tests.go +++ b/tests/integration/group-tests.go @@ -607,6 +607,9 @@ func TestNotImplementedActions(s *S3Conf) { PutBucketLifecycleConfiguration_not_implemented(s) GetBucketLifecycleConfiguration_not_implemented(s) DeleteBucketLifecycle_not_implemented(s) + // bucket logging actions + PutBucketLogging_not_implemented(s) + GetBucketLogging_not_implemented(s) } func TestWORMProtection(s *S3Conf) { @@ -1332,6 +1335,8 @@ func GetIntTests() IntTests { "PutBucketLifecycleConfiguration_not_implemented": PutBucketLifecycleConfiguration_not_implemented, "GetBucketLifecycleConfiguration_not_implemented": GetBucketLifecycleConfiguration_not_implemented, "DeleteBucketLifecycle_not_implemented": DeleteBucketLifecycle_not_implemented, + "PutBucketLogging_not_implemented": PutBucketLogging_not_implemented, + "GetBucketLogging_not_implemented": GetBucketLogging_not_implemented, "WORMProtection_bucket_object_lock_configuration_compliance_mode": WORMProtection_bucket_object_lock_configuration_compliance_mode, "WORMProtection_bucket_object_lock_configuration_governance_mode": WORMProtection_bucket_object_lock_configuration_governance_mode, "WORMProtection_bucket_object_lock_governance_bypass_delete": WORMProtection_bucket_object_lock_governance_bypass_delete, diff --git a/tests/integration/tests.go b/tests/integration/tests.go index 5828688..dbaacae 100644 --- a/tests/integration/tests.go +++ b/tests/integration/tests.go @@ -14924,6 +14924,52 @@ func DeleteBucketLifecycle_not_implemented(s *S3Conf) error { }) } +func PutBucketLogging_not_implemented(s *S3Conf) error { + testName := "PutBucketLogging_not_implemented" + return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { + ctx, cancel := context.WithTimeout(context.Background(), shortTimeout) + _, err := s3client.PutBucketLogging(ctx, + &s3.PutBucketLoggingInput{ + Bucket: &bucket, + BucketLoggingStatus: &types.BucketLoggingStatus{ + LoggingEnabled: &types.LoggingEnabled{ + TargetBucket: &bucket, + TargetGrants: []types.TargetGrant{ + { + Grantee: &types.Grantee{ + Type: types.TypeCanonicalUser, + ID: getPtr("grt1"), + }, + Permission: types.BucketLogsPermissionRead, + }, + }, + TargetObjectKeyFormat: &types.TargetObjectKeyFormat{ + SimplePrefix: &types.SimplePrefix{}, + }, + TargetPrefix: getPtr("prefix"), + }, + }, + }) + cancel() + + return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented)) + }) +} + +func GetBucketLogging_not_implemented(s *S3Conf) error { + testName := "GetBucketLogging_not_implemented" + return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error { + ctx, cancel := context.WithTimeout(context.Background(), shortTimeout) + _, err := s3client.GetBucketLogging(ctx, + &s3.GetBucketLoggingInput{ + Bucket: &bucket, + }) + cancel() + + return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented)) + }) +} + func WORMProtection_bucket_object_lock_configuration_compliance_mode(s *S3Conf) error { testName := "WORMProtection_bucket_object_lock_configuration_compliance_mode" return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {