Skip to content

Commit 6ea4c3b

Browse files
authored
Merge pull request #9329 from naveenpaul1/iam_user_id_deny
IAM | User ID for principal is not supported
2 parents 924a49e + 4585e22 commit 6ea4c3b

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/endpoint/s3/s3_bucket_policy_utils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,19 @@ function get_bucket_policy_principal_arn(account) {
377377
return bucket_policy_arn;
378378
}
379379

380+
/**
381+
* Both NSFS NC and containerized will validate bucket policy against acccount id
382+
* but in containerized deplyment not against IAM user ID.
383+
*
384+
* @param {boolean} is_nc_deployment
385+
* @param {object} account
386+
*/
387+
function get_account_identifier_id(is_nc_deployment, account) {
388+
if (is_nc_deployment || account.owner === undefined) {
389+
return account._id;
390+
}
391+
}
392+
380393
/**
381394
* create_arn_for_root creates the AWS ARN for root account user
382395
* see: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns
@@ -416,3 +429,4 @@ exports.validate_s3_policy = validate_s3_policy;
416429
exports.allows_public_access = allows_public_access;
417430
exports.get_bucket_policy_principal_arn = get_bucket_policy_principal_arn;
418431
exports.create_arn_for_root = create_arn_for_root;
432+
exports.get_account_identifier_id = get_account_identifier_id;

src/endpoint/s3/s3_rest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,10 @@ async function authorize_request_policy(req) {
252252
const account = req.object_sdk.requesting_account;
253253
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();
255-
// Both NSFS NC and containerized will validate bucket policy against acccount id.
256-
const account_identifier_id = account._id;
255+
// Both NSFS NC and containerized will validate bucket policy against acccount id
256+
// but in containerized deplyment not against IAM user ID.
257+
const account_identifier_id = s3_bucket_policy_utils.get_account_identifier_id(is_nc_deployment, account);
257258
const account_identifier_arn = s3_bucket_policy_utils.get_bucket_policy_principal_arn(account);
258-
259259
// deny delete_bucket permissions from bucket_claim_owner accounts (accounts that were created by OBC from openshift\k8s)
260260
// the OBC bucket can still be delete by normal accounts according to the access policy which is checked below
261261
if (req.op_name === 'delete_bucket' && account.bucket_claim_owner) {

src/server/system_services/bucket_server.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,11 @@ async function get_account_by_principal(principal) {
559559
if (principal_by_arn) return true;
560560
} else {
561561
const account = system_store.data.accounts.find(acc => acc._id.toString() === principal_as_string);
562-
const principal_by_id = account !== undefined;
562+
if (account && account.owner) {
563+
dbg.log3('get_account_by_principal: principal_by_id not supported for IAM users');
564+
return false;
565+
}
566+
const principal_by_id = Boolean(account);
563567
dbg.log3('get_account_by_principal: principal_by_id', principal_by_id);
564568
if (principal_by_id) return true;
565569
}

0 commit comments

Comments
 (0)