Skip to content

Commit 3b28440

Browse files
committed
DFBUGS-1517:
This is the put-bucket-policy case for combination of Effect : DENY, Action: $OPERATION, NotPrincipal: $ACCOUNT The $ACCOUNT mentioned in the "NotPrincipal" should be excluded from DENy operation and should be allowed on the $OPERATION Example: For operation get_object, if we have DENY effect for * (all accounts) and we want to give access to any one or few accounts, then that account can be part of "NotPrincipal" Signed-off-by: Vinayakswami Hariharmath <[email protected]>
1 parent a3bc7dd commit 3b28440

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/endpoint/s3/s3_bucket_policy_utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ function _is_principal_fit(account, statement) {
174174
let principal_fit = false;
175175
statement_principal = statement_principal.AWS ? statement_principal.AWS : statement_principal;
176176
for (const principal of _.flatten([statement_principal])) {
177-
dbg.log1('bucket_policy: ', statement.Principal ? 'Principal' : 'NotPrincipal', ' fit?', principal, account);
178-
if ((principal.unwrap() === '*') || (principal.unwrap() === account)) {
177+
dbg.log1('bucket_policy: ', statement.Principal ? 'Principal' : 'NotPrincipal', ' fit?', principal, account.account_identifier_name);
178+
if ((principal.unwrap() === '*') || (principal.unwrap() === account.account_identifier_id) || (principal.unwrap() === account.account_identifier_name)) {
179179
principal_fit = true;
180180
break;
181181
}

src/endpoint/s3/s3_rest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,14 @@ async function authorize_request_policy(req) {
287287
// we start the permission check on account identifier intentionally
288288
if (account_identifier_id) {
289289
permission_by_id = await s3_bucket_policy_utils.has_bucket_policy_permission(
290-
s3_policy, account_identifier_id, method, arn_path, req);
290+
s3_policy, {account_identifier_name, account_identifier_id}, method, arn_path, req);
291291
dbg.log3('authorize_request_policy: permission_by_id', permission_by_id);
292292
}
293293
if (permission_by_id === "DENY") throw new S3Error(S3Error.AccessDenied);
294294

295295
if ((!account_identifier_id || permission_by_id !== "DENY") && account.owner === undefined) {
296296
permission_by_name = await s3_bucket_policy_utils.has_bucket_policy_permission(
297-
s3_policy, account_identifier_name, method, arn_path, req);
297+
s3_policy, {account_identifier_name, account_identifier_id}, method, arn_path, req);
298298
dbg.log3('authorize_request_policy: permission_by_name', permission_by_name);
299299
}
300300
if (permission_by_name === "DENY") throw new S3Error(S3Error.AccessDenied);

0 commit comments

Comments
 (0)