Skip to content

Commit 7f01b91

Browse files
committed
additional fixes
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1 parent b3b4362 commit 7f01b91

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/endpoint/s3/s3_rest.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async function authorize_request_policy(req) {
250250
}
251251

252252
const account = req.object_sdk.requesting_account;
253-
const is_nc_deployment = req.object_sdk.nsfs_config_root;
253+
const is_nc_deployment = Boolean(req.object_sdk.nsfs_config_root);
254254
const account_identifier_name = is_nc_deployment ? account.name.unwrap() : account.email.unwrap();
255255
const account_identifier_id = is_nc_deployment ? account._id : undefined;
256256
const account_identifier_arn = s3_bucket_policy_utils.get_bucket_policy_principal_arn(account);
@@ -322,7 +322,8 @@ async function authorize_request_policy(req) {
322322
// Policy permission is validated by account arn
323323
if (!account_identifier_id) {
324324
permission_by_arn = await s3_bucket_policy_utils.has_bucket_policy_permission(
325-
s3_policy, account_identifier_arn, method, arn_path, req, public_access_block?.restrict_public_buckets
325+
s3_policy, account_identifier_arn, method, arn_path, req,
326+
{ disallow_public_access: public_access_block?.restrict_public_buckets }
326327
);
327328
dbg.log3('authorize_request_policy: permission_by_arn', permission_by_arn);
328329
}
@@ -331,11 +332,12 @@ async function authorize_request_policy(req) {
331332
// ARN check for users under the account
332333
// ARN check is not implemented in NC yet
333334
if (!is_nc_deployment && account.owner !== undefined) {
334-
const owner_account_identifier_arn = s3_bucket_policy_utils.get_bucket_policy_principal_arn(account.owner);
335+
const owner_account_identifier_arn = s3_bucket_policy_utils.create_arn_for_root(account.owner);
335336
permission_by_arn_owner = await s3_bucket_policy_utils.has_bucket_policy_permission(
336-
s3_policy, owner_account_identifier_arn, method, arn_path, req, public_access_block?.restrict_public_buckets
337+
s3_policy, owner_account_identifier_arn, method, arn_path, req,
338+
{ disallow_public_access: public_access_block?.restrict_public_buckets }
337339
);
338-
dbg.log3('authorize_request_policy: permission_by_arn_owner', permission_by_arn_owner);
340+
dbg.log3('authorize_request_policy permission_by_arn_owner', permission_by_arn_owner);
339341
if (permission_by_arn_owner === "DENY") throw new S3Error(S3Error.AccessDenied);
340342
}
341343
if ((permission_by_id === "ALLOW" || permission_by_name === "ALLOW" ||

0 commit comments

Comments
 (0)