Skip to content

Commit

Permalink
Merge pull request #8086 from shirady/nsfs-nc-account-rename
Browse files Browse the repository at this point in the history
NSFS | NC | Add Condition in `authorize_request_policy`
  • Loading branch information
shirady authored Jun 3, 2024
2 parents c4cb185 + a9f2f89 commit 43f3718
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cmd/nsfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class NsfsObjectSDK extends ObjectSDK {
},
system_owner: new SensitiveString('nsfs'),
bucket_owner: new SensitiveString('nsfs'),
owner_account: new SensitiveString('nsfs-id'), // temp
};
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/endpoint/s3/s3_rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async function authorize_request_policy(req) {
if (!req.params.bucket) return;
if (req.op_name === 'put_bucket') return;

const { s3_policy, system_owner, bucket_owner } = await req.object_sdk.read_bucket_sdk_policy_info(req.params.bucket);
const { s3_policy, system_owner, bucket_owner, owner_account } = await req.object_sdk.read_bucket_sdk_policy_info(req.params.bucket);
const auth_token = req.object_sdk.get_auth_token();
const arn_path = _get_arn_from_req_path(req);
const method = _get_method_from_req(req);
Expand All @@ -234,6 +234,7 @@ async function authorize_request_policy(req) {

const is_owner = (function() {
if (account.bucket_claim_owner && account.bucket_claim_owner.unwrap() === req.params.bucket) return true;
if (req.object_sdk.nsfs_config_root && account._id === owner_account.id) return true; // NC NSFS case
if (account_identifier === bucket_owner.unwrap()) return true;
return false;
}());
Expand Down
1 change: 1 addition & 0 deletions src/sdk/object_sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class ObjectSDK {
s3_policy: bucket.s3_policy,
system_owner: bucket.system_owner,
bucket_owner: bucket.bucket_owner,
owner_account: bucket.owner_account, // in NC NSFS this is the account id that owns the bucket
};
return policy_info;
}
Expand Down

0 comments on commit 43f3718

Please sign in to comment.