File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff 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;
416429exports . allows_public_access = allows_public_access ;
417430exports . get_bucket_policy_principal_arn = get_bucket_policy_principal_arn ;
418431exports . create_arn_for_root = create_arn_for_root ;
432+ exports . get_account_identifier_id = get_account_identifier_id ;
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments