Skip to content

Commit

Permalink
undo skip + change the object_md on bucket versioning
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <[email protected]>
  • Loading branch information
shirady committed Sep 30, 2024
1 parent fe6d511 commit fed7524
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/server/object_services/object_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ async function read_node_mapping(req) {
*/
async function read_object_md(req) {
dbg.log1('object_server.read_object_md:', req.rpc_params);
const { bucket, key, md_conditions, adminfo, encryption } = req.rpc_params;
const { bucket, key, md_conditions, adminfo, encryption, version_id } = req.rpc_params;

if (adminfo && req.role !== 'admin') {
throw new RpcError('UNAUTHORIZED', 'read_object_md: role should be admin');
Expand All @@ -785,8 +785,16 @@ async function read_object_md(req) {
const obj = await find_object_md(req);

// Check if the requesting account is authorized to read the object
if (!await req.has_s3_bucket_permission(req.bucket, 's3:GetObject', '/' + obj.key)) {
throw new RpcError('UNAUTHORIZED', 'requesting account is not authorized to read the object');
if (version_id) {
const permission_versioning_enabled = version_id && await req.has_s3_bucket_permission(req.bucket, 's3:GetObjectVersion', '/' + obj.key);
if (!permission_versioning_enabled) {
throw new RpcError('UNAUTHORIZED', 'requesting account is not authorized to read the object');
}
} else {
const permission_versioning_disabled = await req.has_s3_bucket_permission(req.bucket, 's3:GetObject', '/' + obj.key);
if (!permission_versioning_disabled) {
throw new RpcError('UNAUTHORIZED', 'requesting account is not authorized to read the object');
}
}

check_md_conditions(md_conditions, obj);
Expand Down
1 change: 0 additions & 1 deletion src/test/unit_tests/test_s3_bucket_policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ mocha.describe('s3_bucket_policy', function() {
mocha.describe('bucket policy on get object attributes - versioning enabled', async function() {
// currently the read_object in the object server is hard-coded on regular head object permission
// and not flexible to versioned way
if (!is_nc_coretest) this.skip(); // eslint-disable-line no-invalid-this
let version_id;

mocha.before('put object', async function() {
Expand Down

0 comments on commit fed7524

Please sign in to comment.