This document explains the implementation of s3:BypassGovernanceRetention permission in SeaweedFS, providing AWS S3-compatible governance retention bypass functionality.
The governance permission system enables proper AWS S3-compatible object retention with governance mode bypass capabilities. This implementation ensures that only users with the appropriate permissions can bypass governance retention, while maintaining security and compliance requirements.
x-amz-bypass-governance-retention headerPermission Checker
func (s3a *S3ApiServer) checkGovernanceBypassPermission(r *http.Request, bucket, object string) bool
s3:BypassGovernanceRetention permissionObject Lock Permission Validation
func (s3a *S3ApiServer) checkObjectLockPermissions(r *http.Request, bucket, object, versionId string, bypassGovernance bool) error
IAM Integration
ACTION_BYPASS_GOVERNANCE_RETENTION constants3:BypassGovernanceRetention actionRequest with x-amz-bypass-governance-retention: true
↓
Check if object is under retention
↓
If GOVERNANCE mode:
↓
Check if user has s3:BypassGovernanceRetention permission
↓
If permission granted: Allow operation
If permission denied: Deny operation
↓
If COMPLIANCE mode: Always deny
Add governance bypass permission to user actions in identities.json:
{
"identities": [
{
"name": "governance-admin",
"credentials": [{"accessKey": "admin123", "secretKey": "secret123"}],
"actions": [
"Read:my-bucket/*",
"Write:my-bucket/*",
"BypassGovernanceRetention:my-bucket/*"
]
}
]
}
Grant governance bypass permission via bucket policies:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:BypassGovernanceRetention",
"Resource": "arn:aws:s3:::bucket/*"
}
]
}
Note: The policy version should use the standard AWS policy version PolicyVersion2012_10_17 constant (which equals "2012-10-17").
# User with bypass permission
aws s3api delete-object \
--bucket my-bucket \
--key my-object \
--bypass-governance-retention
# Admin user (always allowed)
aws s3api delete-object \
--bucket my-bucket \
--key my-object \
--bypass-governance-retention
# Extend retention period (requires bypass permission for governance mode)
aws s3api put-object-retention \
--bucket my-bucket \
--key my-object \
--retention Mode=GOVERNANCE,RetainUntilDate=2025-01-01T00:00:00Z \
--bypass-governance-retention
# Delete multiple objects with governance bypass
aws s3api delete-objects \
--bucket my-bucket \
--delete file://delete-objects.json \
--bypass-governance-retention
s3:BypassGovernanceRetention permission<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>AccessDenied</Code>
<Message>User does not have permission to bypass governance retention</Message>
<RequestId>abc123</RequestId>
<Resource>/my-bucket/my-object</Resource>
</Error>
# Run governance permission tests
go test -v ./weed/s3api/ -run TestGovernance
# Run all object retention tests
go test -v ./weed/s3api/ -run TestObjectRetention
# Test with real S3 clients
cd test/s3/retention
go test -v ./... -run TestGovernanceBypass
This implementation provides full AWS S3 compatibility for:
x-amz-bypass-governance-retention header supports3:BypassGovernanceRetention permissionUser cannot bypass governance retention
s3:BypassGovernanceRetention permissionx-amz-bypass-governance-retention: true is setAdmin bypass not working
Policy not taking effect