Skip to content

rgw: add s3control apis for account-wide PublicAccessBlock - #64293

Merged
cbodley merged 18 commits into
ceph:mainfrom
cbodley:wip-71265
May 27, 2026
Merged

cbodley merged 18 commits into
ceph:mainfrom
cbodley:wip-71265

Conversation

@cbodley

@cbodley cbodley commented Jul 1, 2025 •

Copy link
Copy Markdown
Contributor

we already support bucket-level PublicAccessBlock configuration through s3 PutBucketPublicAccessBlock. add support for s3control PutPublicAccessBlock to set configuration for a whole account. when both bucket and account configurations are present, take their union

rgw_enable_apis supports a new "s3control" entry that registers a RGWRESTMgr for the path "/v20180820/configuration/publicAccessBlock". because this path is hosted at the same endpoint as the s3 namespace, this would conflict with buckets named "v20180820". for that reason, "s3control" is not enabled by default in rgw_enable_apis presence of the request header x-amz-account-id is used to disambiguate

https://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-account.html

Fixes: https://tracker.ceph.com/issues/71265

Show available Jenkins commands

@cbodley

cbodley commented Jul 1, 2025

Copy link
Copy Markdown
Contributor Author

passing test case in ceph/s3-tests#669

@cbodley
cbodley marked this pull request as ready for review July 1, 2025 16:26
@cbodley
cbodley requested a review from a team as a code owner July 1, 2025 16:26
@adamemerson

Copy link
Copy Markdown
Contributor

make check arm64

@adamemerson adamemerson self-assigned this Jul 2, 2025
@cbodley

cbodley commented Jul 2, 2025

Copy link
Copy Markdown
Contributor Author

i'm not sure why, but boto3 is adding the value of x-amz-account-id to the beginning of the host header for s3control requests:

HTTP_HOST=rgw11111111111111111.localhost:8000

when rgw_dns_name is set to localhost, this triggers our vhost-style logic which rewrites the path:

final domain/bucket subdomain=rgw11111111111111111 domain=localhost in_hosted_domain=1 in_hosted_domain_s3website=0 s->info.domain=localhost s->info.request_uri=/rgw11111111111111111/v20180820/configuration/publicAccessBlock

this doesn't match the path /v20180820/ so gets misinterpreted as s3. i think we need to change the vhost logic so it only applies to s3 requests

@github-actions

github-actions Bot commented Jul 3, 2025

Copy link
Copy Markdown

Config Diff Tool Output

! changed: rgw_enable_apis: old: s3, s3website, swift, swift_auth, admin, sts, iam, notifications (rgw.yaml.in)
! changed: rgw_enable_apis: new: s3, s3control, s3website, swift, swift_auth, admin, sts, iam, notifications (rgw.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@cbodley

cbodley commented Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

this doesn't match the path /v20180820/ so gets misinterpreted as s3. i think we need to change the vhost logic so it only applies to s3 requests

added commits up to "rgw/s3: apply vhost logic to s3 only" to resolve this

@cbodley

cbodley commented Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

rgw_enable_apis supports a new "s3control" entry that registers a RGWRESTMgr for the path "/v20180820/configuration/publicAccessBlock". because this path is hosted at the same endpoint as the s3 namespace, this would conflict with buckets named "v20180820". for that reason, "s3control" is not enabled by default in rgw_enable_apis

the routing in RGWRESTMgr_S3 now tests for the x-amz-account-id request header to disambiguate, allowing the s3control api to be enabled by default:

  // s3control apis all expect the request header x-amz-account-id,
  // and s3 apis don't. use that to disambiguate between s3control
  // and requests to s3 buckets named v20180820
  if (s3control && s->info.env->exists("HTTP_X_AMZ_ACCOUNT_ID")) {

@clwluvw

clwluvw commented Jul 3, 2025

Copy link
Copy Markdown
Member

i'm not sure why, but boto3 is adding the value of x-amz-account-id to the beginning of the host header for s3control requests:

HTTP_HOST=rgw11111111111111111.localhost:8000

Apparently AWS serves s3-control API per account: https://docs.aws.amazon.com/general/latest/gr/s3.html#auto-endpoints-control-s3

@yuvalif

yuvalif commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

rgw_enable_apis supports a new "s3control" entry that registers a RGWRESTMgr for the path "/v20180820/configuration/publicAccessBlock". because this path is hosted at the same endpoint as the s3 namespace, this would conflict with buckets named "v20180820". for that reason, "s3control" is not enabled by default in rgw_enable_apis

the routing in RGWRESTMgr_S3 now tests for the x-amz-account-id request header to disambiguate, allowing the s3control api to be enabled by default:

  // s3control apis all expect the request header x-amz-account-id,
  // and s3 apis don't. use that to disambiguate between s3control
  // and requests to s3 buckets named v20180820
  if (s3control && s->info.env->exists("HTTP_X_AMZ_ACCOUNT_ID")) {

so i guess this means we do not need a dedicated RGW endpoint for s3control

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@cbodley

cbodley commented Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

rebased over conflicts with #64251

Comment thread src/rgw/rgw_rest_s3.cc
{
// s3control apis all expect the request header x-amz-account-id,
// and s3 apis don't. use that to disambiguate between s3control
// and requests to s3 buckets named v20180820

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.


int RGWDeletePublicAccessBlock_S3Control::verify_permission(optional_yield y)
{
const rgw::ARN arn{"", "root", account_id, false}; // XXX

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the XXX because we need a proper ARN type for the account resource to modify?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, forgot about the XXX comment

it's a bit unclear what "Resource" arn is expected for iam policies when the resource is an account. afaik aws doesn't have an arn format for accounts, but this account-root-user arn seems to be the closest thing. this was discussed recently in #63945 (comment) for iam:GetAccountSummary so i did the same here

what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in #68429 i had added a rgw::account::root_arn() helper function for exactly this, so i've updated this to use it

@adamemerson

Copy link
Copy Markdown
Contributor

jenkins test make check

@adamemerson

Copy link
Copy Markdown
Contributor

I assume this needs s3-tests as well for QA.

@adamemerson adamemerson removed their assignment Jul 31, 2025
@cbodley

cbodley commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

I assume this needs s3-tests as well for QA.

thanks for review! will schedule qa against ceph/s3-tests#669

cbodley added 6 commits May 20, 2026 10:20
the vhost-style transformations ran in RGWREST::preprocess() before we
even route the request, so applied to every REST API in radosgw

vhost-style requests are specific to the S3 API, so they should only
apply after being routed to RGWRESTMgr_S3

extract the vhost logic from RGWREST::proprocess() into
rgw_rest_transform_s3_vhost_style(), and call that only from
RGWRESTMgr_S3::get_resource_mgr_as_default()

url-decoding of request_uri into decoded_uri is now duplicated in
preprocess() to apply to all requests, then again after vhost-style
transforms the request_uri

Signed-off-by: Casey Bodley <[email protected]>
s3tests for s3control and iam apis need to know the account id

Signed-off-by: Casey Bodley <[email protected]>
i would prefer to run the s3control test coverage in rgw/verify, but it
depends on rgw_dns_name configuration and support for wildcard dns which
breaks most of the other rgw/verify test cases

Signed-off-by: Casey Bodley <[email protected]>
this 'keytool' invocation was moved from qa/tasks/s3tests_java.py to
qa/tasks/rgw.py so that it would also cover the java checksum tests

but that means it runs for any rgw job with https enabled, even if it
doesn't install or use any java stuff. the 'keytool' command itself
comes from jdk packages which aren't installed by default

ignore errors from this command so that subsuites can use https without
installing java

Signed-off-by: Casey Bodley <[email protected]>
@cbodley

cbodley commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

https://jenkins.ceph.com/job/ceph-pull-requests-arm64/94200/

The following tests FAILED:
273 - unittest_posix_bucket_cache (Timeout)

@cbodley

cbodley commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@cbodley

cbodley commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

allow access to admin users that don't belong to the requested account.
this is also necessary for multisite, where requests are forwarded to
the metadata master as the multisite system user instead of the original
requester

Signed-off-by: Casey Bodley <[email protected]>
@cbodley

cbodley commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

i've raised a separate pr #69111 for documentation changes so they can be reviewed without delaying merge here

@batrick batrick added this to the umbrella milestone May 26, 2026
@batrick

batrick commented May 26, 2026

Copy link
Copy Markdown
Member

Please share regular updates on this umbrella branch blocker in #ceph-upstream-releases-umbrella on Slack.

@cbodley
cbodley merged commit 61cd751 into ceph:main May 27, 2026
5 of 6 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/26513056995

@cbodley
cbodley deleted the wip-71265 branch May 27, 2026 13:28
@batrick batrick modified the milestones: umbrella, v21.1.1 Jul 29, 2026
adamemerson added a commit to adamemerson/ceph that referenced this pull request Aug 20, 2026
When the `rgw_copious_policy_logging` option is set to true, a
detailed trace of policy evaluation is logged.

Assisted-by: Claude Opus 4.6 <[email protected]>
(I wanted to see how it performed on rebase conflict resolution.)
Assisted-by: Claude Fable 5 <[email protected]>
(I figured I should have it look at the policy evaluation code for
bugs while it's included, and it found a few mistakes in output.)
Signed-off-by: Adam C. Emerson <[email protected]>

Conflicts:
	src/common/options/rgw.yaml.in
 - Intervening options in upstream and other backports
	src/rgw/rgw_bucket_logging.cc
 - Clash with minimal environment production from
   <ceph#69264>.
	src/rgw/rgw_common.cc
	src/rgw/rgw_op.cc
 - Clash with change in `RestrictPublicBuckets` handling in
   <ceph#64293>.
	src/test/rgw/test_rgw_iam_policy.cc
 - Original commit modified upstream tests (keystone, etc.) not in
   downstream

Fixes: https://tracker.ceph.com/issues/78662
(cherry picked from commit 7bdb627)
batrick pushed a commit to adamemerson/ceph that referenced this pull request Aug 21, 2026
When the `rgw_copious_policy_logging` option is set to true, a
detailed trace of policy evaluation is logged.

Assisted-by: Claude Opus 4.6 <[email protected]>
(I wanted to see how it performed on rebase conflict resolution.)
Assisted-by: Claude Fable 5 <[email protected]>
(I figured I should have it look at the policy evaluation code for
bugs while it's included, and it found a few mistakes in output.)
Signed-off-by: Adam C. Emerson <[email protected]>

Conflicts:
	src/common/options/rgw.yaml.in
 - Intervening options in upstream and other backports
	src/rgw/rgw_bucket_logging.cc
 - Clash with minimal environment production from
   <ceph#69264>.
	src/rgw/rgw_common.cc
	src/rgw/rgw_op.cc
 - Clash with change in `RestrictPublicBuckets` handling in
   <ceph#64293>.
	src/test/rgw/test_rgw_iam_policy.cc
 - Original commit modified upstream tests (keystone, etc.) not in
   downstream

Fixes: https://tracker.ceph.com/issues/78662
(cherry picked from commit 7bdb627)
adamemerson added a commit to adamemerson/ceph that referenced this pull request Sep 21, 2026
When the `rgw_copious_policy_logging` option is set to true, a
detailed trace of policy evaluation is logged.

Assisted-by: Claude Opus 4.6 <[email protected]>
(I wanted to see how it performed on rebase conflict resolution.)
Assisted-by: Claude Fable 5 <[email protected]>
(I figured I should have it look at the policy evaluation code for
bugs while it's included, and it found a few mistakes in output.)
Signed-off-by: Adam C. Emerson <[email protected]>

Conflicts:
	src/common/options/rgw.yaml.in
 - Intervening options in upstream and other backports
	src/rgw/rgw_bucket_logging.cc
 - Clash with minimal environment production from
   <ceph#69264>.
	src/rgw/rgw_common.cc
	src/rgw/rgw_op.cc
 - Clash with change in `RestrictPublicBuckets` handling in
   <ceph#64293>.
	src/test/rgw/test_rgw_iam_policy.cc
 - Original commit modified upstream tests (keystone, etc.) not in
   downstream

Fixes: https://tracker.ceph.com/issues/78662
(cherry picked from commit 7bdb627)
adamemerson added a commit to adamemerson/ceph that referenced this pull request Oct 9, 2026
When the `rgw_copious_policy_logging` option is set to true, a
detailed trace of policy evaluation is logged.

Assisted-by: Claude Opus 4.6 <[email protected]>
(I wanted to see how it performed on rebase conflict resolution.)
Assisted-by: Claude Fable 5 <[email protected]>
(I figured I should have it look at the policy evaluation code for
bugs while it's included, and it found a few mistakes in output.)
Signed-off-by: Adam C. Emerson <[email protected]>

Conflicts:
	src/common/options/rgw.yaml.in
 - Intervening options in upstream and other backports
	src/rgw/rgw_bucket_logging.cc
 - Clash with minimal environment production from
   <ceph#69264>.
	src/rgw/rgw_common.cc
	src/rgw/rgw_op.cc
 - Clash with change in `RestrictPublicBuckets` handling in
   <ceph#64293>.
	src/test/rgw/test_rgw_iam_policy.cc
 - Original commit modified upstream tests (keystone, etc.) not in
   downstream

Fixes: https://tracker.ceph.com/issues/78662
(cherry picked from commit 7bdb627)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants