Project

General

Profile

Actions

Feature #70086

closed

support service principals in bucket policy

Added by Yuval Lifshitz about 1 year ago. Updated 6 months ago.

Status:
Resolved
Priority:
Normal
Target version:
-
% Done:

0%

Source:
Backport:
Reviewed:
Affected Versions:
Pull request ID:
Tags (freeform):
Fixed In:
v20.0.0-957-g444f8651ec
Released In:
v20.2.0~697
Upkeep Timestamp:
2025-11-01T01:14:20+00:00

Description

as a minimum we should support policies as described here:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-server-access-logging.html#grant-log-delivery-permissions-bucket-policy

with ARN and source account as conditions.

Actions #1

Updated by Casey Bodley about 1 year ago

from the example bucket policy in https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-server-access-logging.html#grant-log-delivery-permissions-bucket-policy:

            "Principal": {
                "Service": "logging.s3.amazonaws.com" 
            },

we'll first need to teach the iam policy parser about Service principals. that would happen in rgw_iam_policy.cc:parse_principal() and probably involve adding Service to the Principal::types enum

the bucket logging code would then call through verify_bucket_permission() to evaluate_iam_policies(), where the given const rgw::auth::Identity& identity would override Identity::is_identity(const Principal& p) to match such a service principal

            "Condition": {
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:s3:::amzn-s3-demo-source-bucket" 
                },
                "StringEquals": {
                    "aws:SourceAccount": "SOURCE-ACCOUNT-ID" 
                }
            }

evaluate_iam_policies() uses the given const rgw::IAM::Environment& env to match conditions like this. the bucket logging code would have to add key/value pairs for these keys to that environment. you can find some examples of this in rgw_op.cc by searching for rgw_add_to_iam_environment(). for aws:SourceAccount, you should be able to use to_string(source_bucket_info.owner) as the value to match both user- and account owners

Actions #2

Updated by Yuval Lifshitz about 1 year ago

  • Status changed from New to In Progress
  • Pull request ID set to 62284
Actions #3

Updated by Yuval Lifshitz about 1 year ago

  • Status changed from In Progress to Resolved
Actions #4

Updated by Upkeep Bot 10 months ago

  • Merge Commit set to 444f8651ec82fe06152275f23a628871270dc639
  • Fixed In set to v20.0.0-957-g444f8651ec8
  • Upkeep Timestamp set to 2025-07-09T19:36:59+00:00
Actions #5

Updated by Upkeep Bot 10 months ago

  • Fixed In changed from v20.0.0-957-g444f8651ec8 to v20.0.0-957-g444f8651ec
  • Upkeep Timestamp changed from 2025-07-09T19:36:59+00:00 to 2025-07-14T18:13:54+00:00
Actions #6

Updated by Upkeep Bot 6 months ago

  • Released In set to v20.2.0~697
  • Upkeep Timestamp changed from 2025-07-14T18:13:54+00:00 to 2025-11-01T01:14:20+00:00
Actions

Also available in: Atom PDF