Skip to content

Commit 6e24c2e

Browse files
committed
CR changes
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
1 parent aa4dfa5 commit 6e24c2e

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/endpoint/iam/iam_utils.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,17 @@ function get_iam_username(requested_account_name) {
6767
}
6868

6969
/**
70-
* _create_detailed_message_for_access_in_s3 returns a detailed message with details needed for user who
70+
* _create_detailed_message_for_iam_user_access_in_s3 returns a detailed message with details needed for user who
7171
* tried to perform S3 operation
7272
* - resource_arn is only relevant for operations related to a bucket
73-
* @param {object} requesting_account
73+
* @param {object} user_account
7474
* @param {string|string[]} method
7575
* @param {string} resource_arn
7676
*/
77-
function _create_detailed_message_for_access_in_s3(requesting_account, method, resource_arn) {
78-
const arn_for_requesting_account = create_arn_for_user(requesting_account.owner,
79-
get_iam_username(requesting_account.name.unwrap()), requesting_account.iam_path);
77+
function _create_detailed_message_for_iam_user_access_in_s3(user_account, method, resource_arn) {
78+
const owner_account_id = get_owner_account_id(user_account);
79+
const arn_for_requesting_account = create_arn_for_user(owner_account_id,
80+
get_iam_username(user_account.name.unwrap()), user_account.iam_path);
8081
const full_action_name = Array.isArray(method) && method.length > 1 ? method[1] : method; // special case for get_object_attributes
8182

8283
const message_start = `User: ${arn_for_requesting_account} is not authorized to perform: ${full_action_name} `;
@@ -878,5 +879,5 @@ exports.validate_tag_user_params = validate_tag_user_params;
878879
exports.validate_untag_user_params = validate_untag_user_params;
879880
exports.validate_list_user_tags_params = validate_list_user_tags_params;
880881
exports.get_owner_account_id = get_owner_account_id;
881-
exports._create_detailed_message_for_access_in_s3 = _create_detailed_message_for_access_in_s3;
882+
exports._create_detailed_message_for_iam_user_access_in_s3 = _create_detailed_message_for_iam_user_access_in_s3;
882883

src/endpoint/s3/s3_rest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const http_utils = require('../../util/http_utils');
1414
const signature_utils = require('../../util/signature_utils');
1515
const config = require('../../../config');
1616
const s3_utils = require('./s3_utils');
17-
const { _create_detailed_message_for_access_in_s3 } = require('../iam/iam_utils'); // authorize_request for IAM policy
17+
const { _create_detailed_message_for_iam_user_access_in_s3 } = require('../iam/iam_utils'); // for IAM policy
1818

1919
const S3_MAX_BODY_LEN = 4 * 1024 * 1024;
2020

@@ -378,7 +378,7 @@ async function authorize_request_iam_policy(req) {
378378
}
379379

380380
function _throw_iam_access_denied_error_for_s3_operation(requesting_account, method, resource_arn) {
381-
const message_with_details = _create_detailed_message_for_access_in_s3(requesting_account, method, resource_arn);
381+
const message_with_details = _create_detailed_message_for_iam_user_access_in_s3(requesting_account, method, resource_arn);
382382
const { code, http_code } = S3Error.AccessDenied;
383383
throw new S3Error({ code, message: message_with_details, http_code});
384384
}

0 commit comments

Comments
 (0)