Skip to content

Commit 5f28a74

Browse files
committed
feat: adds not implemented routes for bucket logging actions
Closes #1444 Adds `NotImplemented` routes for bucket logging S3 actions: - `PutBucketLogging` - `GetBucketLogging`
1 parent 025b0ee commit 5f28a74

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

auth/bucket_policy_actions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const (
7070
GetInventoryConfigurationAction Action = "s3:GetInventoryConfiguration"
7171
PutLifecycleConfigurationAction Action = "s3:PutLifecycleConfiguration"
7272
GetLifecycleConfigurationAction Action = "s3:GetLifecycleConfiguration"
73+
PutBucketLoggingAction Action = "s3:PutBucketLogging"
74+
GetBucketLoggingAction Action = "s3:GetBucketLogging"
7375

7476
AllActions Action = "s3:*"
7577
)

metrics/actions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ var (
9393
ActionPutBucketLifecycleConfiguration = "s3_PutBucketLifecycleConfiguration"
9494
ActionGetBucketLifecycleConfiguration = "s3_GetBucketLifecycleConfiguration"
9595
ActionDeleteBucketLifecycle = "s3_DeleteBucketLifecycle"
96+
ActionPutBucketLogging = "s3_PutBucketLogging"
97+
ActionGetBucketLogging = "s3_GetBucketLogging"
9698

9799
// Admin actions
98100
ActionAdminCreateUser = "admin_CreateUser"

s3api/router.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ
265265
middlewares.ParseAcl(be),
266266
),
267267
)
268+
bucketRouter.Put("",
269+
middlewares.MatchQueryArgs("logging"),
270+
controllers.ProcessHandlers(
271+
ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)),
272+
metrics.ActionPutBucketLogging,
273+
services,
274+
middlewares.BucketObjectNameValidator(),
275+
middlewares.AuthorizePublicBucketAccess(be, metrics.ActionPutBucketLogging, auth.PutBucketLoggingAction, auth.PermissionWrite),
276+
middlewares.VerifyPresignedV4Signature(root, iam, region, debug),
277+
middlewares.VerifyV4Signature(root, iam, region, debug),
278+
middlewares.VerifyMD5Body(),
279+
middlewares.ParseAcl(be),
280+
),
281+
)
268282
bucketRouter.Put("",
269283
controllers.ProcessHandlers(
270284
ctrl.CreateBucket,
@@ -657,6 +671,20 @@ func (sa *S3ApiRouter) Init(app *fiber.App, be backend.Backend, iam auth.IAMServ
657671
middlewares.ParseAcl(be),
658672
),
659673
)
674+
bucketRouter.Get("",
675+
middlewares.MatchQueryArgs("logging"),
676+
controllers.ProcessHandlers(
677+
ctrl.HandleErrorRoute(s3err.GetAPIError(s3err.ErrNotImplemented)),
678+
metrics.ActionGetBucketLogging,
679+
services,
680+
middlewares.BucketObjectNameValidator(),
681+
middlewares.AuthorizePublicBucketAccess(be, metrics.ActionGetBucketLogging, auth.GetBucketLoggingAction, auth.PermissionRead),
682+
middlewares.VerifyPresignedV4Signature(root, iam, region, debug),
683+
middlewares.VerifyV4Signature(root, iam, region, debug),
684+
middlewares.VerifyMD5Body(),
685+
middlewares.ParseAcl(be),
686+
),
687+
)
660688
bucketRouter.Get("",
661689
middlewares.MatchQueryArgWithValue("list-type", "2"),
662690
controllers.ProcessHandlers(

tests/integration/group-tests.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,9 @@ func TestNotImplementedActions(s *S3Conf) {
607607
PutBucketLifecycleConfiguration_not_implemented(s)
608608
GetBucketLifecycleConfiguration_not_implemented(s)
609609
DeleteBucketLifecycle_not_implemented(s)
610+
// bucket logging actions
611+
PutBucketLogging_not_implemented(s)
612+
GetBucketLogging_not_implemented(s)
610613
}
611614

612615
func TestWORMProtection(s *S3Conf) {
@@ -1332,6 +1335,8 @@ func GetIntTests() IntTests {
13321335
"PutBucketLifecycleConfiguration_not_implemented": PutBucketLifecycleConfiguration_not_implemented,
13331336
"GetBucketLifecycleConfiguration_not_implemented": GetBucketLifecycleConfiguration_not_implemented,
13341337
"DeleteBucketLifecycle_not_implemented": DeleteBucketLifecycle_not_implemented,
1338+
"PutBucketLogging_not_implemented": PutBucketLogging_not_implemented,
1339+
"GetBucketLogging_not_implemented": GetBucketLogging_not_implemented,
13351340
"WORMProtection_bucket_object_lock_configuration_compliance_mode": WORMProtection_bucket_object_lock_configuration_compliance_mode,
13361341
"WORMProtection_bucket_object_lock_configuration_governance_mode": WORMProtection_bucket_object_lock_configuration_governance_mode,
13371342
"WORMProtection_bucket_object_lock_governance_bypass_delete": WORMProtection_bucket_object_lock_governance_bypass_delete,

tests/integration/tests.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14924,6 +14924,52 @@ func DeleteBucketLifecycle_not_implemented(s *S3Conf) error {
1492414924
})
1492514925
}
1492614926

14927+
func PutBucketLogging_not_implemented(s *S3Conf) error {
14928+
testName := "PutBucketLogging_not_implemented"
14929+
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
14930+
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
14931+
_, err := s3client.PutBucketLogging(ctx,
14932+
&s3.PutBucketLoggingInput{
14933+
Bucket: &bucket,
14934+
BucketLoggingStatus: &types.BucketLoggingStatus{
14935+
LoggingEnabled: &types.LoggingEnabled{
14936+
TargetBucket: &bucket,
14937+
TargetGrants: []types.TargetGrant{
14938+
{
14939+
Grantee: &types.Grantee{
14940+
Type: types.TypeCanonicalUser,
14941+
ID: getPtr("grt1"),
14942+
},
14943+
Permission: types.BucketLogsPermissionRead,
14944+
},
14945+
},
14946+
TargetObjectKeyFormat: &types.TargetObjectKeyFormat{
14947+
SimplePrefix: &types.SimplePrefix{},
14948+
},
14949+
TargetPrefix: getPtr("prefix"),
14950+
},
14951+
},
14952+
})
14953+
cancel()
14954+
14955+
return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented))
14956+
})
14957+
}
14958+
14959+
func GetBucketLogging_not_implemented(s *S3Conf) error {
14960+
testName := "GetBucketLogging_not_implemented"
14961+
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {
14962+
ctx, cancel := context.WithTimeout(context.Background(), shortTimeout)
14963+
_, err := s3client.GetBucketLogging(ctx,
14964+
&s3.GetBucketLoggingInput{
14965+
Bucket: &bucket,
14966+
})
14967+
cancel()
14968+
14969+
return checkApiErr(err, s3err.GetAPIError(s3err.ErrNotImplemented))
14970+
})
14971+
}
14972+
1492714973
func WORMProtection_bucket_object_lock_configuration_compliance_mode(s *S3Conf) error {
1492814974
testName := "WORMProtection_bucket_object_lock_configuration_compliance_mode"
1492914975
return actionHandler(s, testName, func(s3client *s3.Client, bucket string) error {

0 commit comments

Comments
 (0)