@@ -7,7 +7,7 @@ const net = require('net');
77const dbg = require ( '../../util/debug_module' ) ( __filename ) ;
88const s3_ops = require ( './ops' ) ;
99const S3Error = require ( './s3_errors' ) . S3Error ;
10- const s3_bucket_policy_utils = require ( './s3_bucket_policy_utils ' ) ;
10+ const access_policy_utils = require ( '../../util/access_policy_utils ' ) ;
1111const s3_logging = require ( './s3_bucket_logging' ) ;
1212const time_utils = require ( '../../util/time_utils' ) ;
1313const http_utils = require ( '../../util/http_utils' ) ;
@@ -254,8 +254,8 @@ async function authorize_request_policy(req) {
254254 const account_identifier_name = is_nc_deployment ? account . name . unwrap ( ) : account . email . unwrap ( ) ;
255255 // Both NSFS NC and containerized will validate bucket policy against acccount id
256256 // 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 ) ;
258- const account_identifier_arn = s3_bucket_policy_utils . get_bucket_policy_principal_arn ( account ) ;
257+ const account_identifier_id = access_policy_utils . get_account_identifier_id ( is_nc_deployment , account ) ;
258+ const account_identifier_arn = access_policy_utils . get_bucket_policy_principal_arn ( account ) ;
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 ) {
@@ -304,7 +304,7 @@ async function authorize_request_policy(req) {
304304 // 2. account id
305305 // we start the permission check on account identifier intentionally
306306 if ( account_identifier_id ) {
307- permission_by_id = await s3_bucket_policy_utils . has_bucket_policy_permission (
307+ permission_by_id = await access_policy_utils . has_access_policy_permission (
308308 s3_policy , account_identifier_id , method , arn_path , req ,
309309 { disallow_public_access : public_access_block ?. restrict_public_buckets }
310310 ) ;
@@ -313,7 +313,7 @@ async function authorize_request_policy(req) {
313313 if ( permission_by_id === "DENY" ) throw new S3Error ( S3Error . AccessDenied ) ;
314314 // Check bucket policy permission against account name only for NSFS NC
315315 if ( is_nc_deployment && permission_by_id !== "DENY" && account . owner === undefined ) {
316- permission_by_name = await s3_bucket_policy_utils . has_bucket_policy_permission (
316+ permission_by_name = await access_policy_utils . has_access_policy_permission (
317317 s3_policy , account_identifier_name , method , arn_path , req ,
318318 { disallow_public_access : public_access_block ?. restrict_public_buckets }
319319 ) ;
@@ -323,7 +323,7 @@ async function authorize_request_policy(req) {
323323 // Check bucket policy permission against ARN only for containerized deployments.
324324 // Policy permission is validated by account arn
325325 if ( ! is_nc_deployment && permission_by_id !== "DENY" ) {
326- permission_by_arn = await s3_bucket_policy_utils . has_bucket_policy_permission (
326+ permission_by_arn = await access_policy_utils . has_access_policy_permission (
327327 s3_policy , account_identifier_arn , method , arn_path , req ,
328328 { disallow_public_access : public_access_block ?. restrict_public_buckets }
329329 ) ;
@@ -335,8 +335,8 @@ async function authorize_request_policy(req) {
335335 // ARN check is not implemented in NC yet
336336 if ( ! is_nc_deployment && account . owner !== undefined ) {
337337 const owner_account_id = get_owner_account_id ( account ) ;
338- const owner_account_identifier_arn = s3_bucket_policy_utils . create_arn_for_root ( owner_account_id ) ;
339- permission_by_owner = await s3_bucket_policy_utils . has_bucket_policy_permission (
338+ const owner_account_identifier_arn = access_policy_utils . create_arn_for_root ( owner_account_id ) ;
339+ permission_by_owner = await access_policy_utils . has_access_policy_permission (
340340 s3_policy , [ owner_account_identifier_arn , owner_account_id ] , method , arn_path , req ,
341341 { disallow_public_access : public_access_block ?. restrict_public_buckets }
342342 ) ;
@@ -371,8 +371,7 @@ async function authorize_request_iam_policy(req) {
371371 // parallel policy check
372372 const promises = [ ] ;
373373 for ( const iam_policy of iam_policies ) {
374- // We are reusing the bucket policy util function as it checks the policy document
375- const promise = s3_bucket_policy_utils . has_bucket_policy_permission (
374+ const promise = access_policy_utils . has_access_policy_permission (
376375 iam_policy . policy_document , undefined , method , resource_arn , req ,
377376 { should_pass_principal : false }
378377 ) ;
@@ -403,7 +402,7 @@ function _throw_iam_access_denied_error_for_s3_operation(requesting_account, met
403402async function authorize_anonymous_access ( s3_policy , method , arn_path , req , public_access_block ) {
404403 if ( ! s3_policy ) throw new S3Error ( S3Error . AccessDenied ) ;
405404
406- const permission = await s3_bucket_policy_utils . has_bucket_policy_permission (
405+ const permission = await access_policy_utils . has_access_policy_permission (
407406 s3_policy , undefined , method , arn_path , req ,
408407 { disallow_public_access : public_access_block ?. restrict_public_buckets }
409408 ) ;
@@ -418,7 +417,7 @@ async function authorize_anonymous_access(s3_policy, method, arn_path, req, publ
418417 * @returns {string|string[] }
419418 */
420419function _get_method_from_req ( req ) {
421- const s3_op = s3_bucket_policy_utils . OP_NAME_TO_ACTION [ req . op_name ] ;
420+ const s3_op = access_policy_utils . OP_NAME_TO_ACTION [ req . op_name ] ;
422421 if ( ! s3_op ) {
423422 dbg . error ( `Got a not supported S3 op ${ req . op_name } - doesn't suppose to happen` ) ;
424423 throw new S3Error ( S3Error . InternalError ) ;
0 commit comments