Skip to content

Commit

Permalink
Set default bucket encryption during bucket creation
Browse files Browse the repository at this point in the history
All S3 buckets have encryption configured by default,
and objects are automatically encrypted by using server
side encryption. When we do get-bucker-encryption on
any bucket we get the the default encryption configuration.

With this patch we set default encryption on bucket while
creating the bucket and follow the behavior of S3 bucket

Signed-off-by: Vinayakswami Hariharmath <[email protected]>
  • Loading branch information
vh05 committed Jan 8, 2025
1 parent 5c4b49b commit 3bb511a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/server/system_services/bucket_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ async function create_bucket(req) {
bucket.bucket_claim = req.rpc_params.bucket_claim;
}
bucket.force_md5_etag = req.rpc_params.force_md5_etag;
bucket.encryption = {
"algorithm": "AES256",
};
changes.insert.buckets = [bucket];
changes.insert.master_keys = [bucket_m_key];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,6 @@ s3tests_boto3/functional/test_s3.py::test_lifecycle_expiration_size_lt
s3tests_boto3/functional/test_s3.py::test_object_lock_delete_multipart_object_with_retention
s3tests_boto3/functional/test_s3.py::test_object_lock_delete_multipart_object_with_legal_hold_on
s3tests_boto3/functional/test_s3.py::test_get_undefined_public_block
s3tests_boto3/functional/test_s3.py::test_get_public_block_deny_bucket_policy
s3tests_boto3/functional/test_s3.py::test_get_public_block_deny_bucket_policy
s3tests_boto3/functional/test_s3.py::test_get_bucket_encryption_s3
s3tests_boto3/functional/test_s3.py::test_get_bucket_encryption_kms
18 changes: 13 additions & 5 deletions src/test/unit_tests/test_s3_encryption.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,22 @@ mocha.describe('Bucket Encryption Operations', async () => {
await local_s3.createBucket({ Bucket: BKT });
});

mocha.it('should get bucket encryption error without encryption configured', async () => {
mocha.it('getBucketEncryption should return the default server side encryption configuration', async () => {
try {
const res = await local_s3.getBucketEncryption({ Bucket: BKT });
throw new Error(`Expected to get error with unconfigured bucket encryption ${res}`);
const expected_response = {
ServerSideEncryptionConfiguration: {
Rules: [{
ApplyServerSideEncryptionByDefault: {
SSEAlgorithm: 'AES256'
}
}]
}
};
const res_without_metadata = _.omit(res, '$metadata');
assert.deepEqual(res_without_metadata, expected_response);
} catch (error) {
assert(error.message === 'The server side encryption configuration was not found.', `Error message does not match got: ${error.message}`);
assert(error.Code === 'ServerSideEncryptionConfigurationNotFoundError', `Error code does not match got: ${error.Code}`);
assert(error.$metadata.httpStatusCode === 404, `Error status code does not match got: ${error.$metadata.httpStatusCode}`);
throw new Error(`The server side encryption configuration was not found ${error.message}`);
}
});

Expand Down

0 comments on commit 3bb511a

Please sign in to comment.