From: Marcus Watts Date: Thu, 7 Jul 2022 07:33:31 +0000 (-0400) Subject: rgw: better tenant id from the uri on anonymous access X-Git-Tag: v17.2.4~125^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F47342%2Fhead;p=ceph.git rgw: better tenant id from the uri on anonymous access When anonymous tries access public bucket, it gets 404, because rgw doesn't check tenant correctly. A previous fix for this broke legacy implicit tenants, because it didn't check for anonymous access. This version restricts its behavior to the anonymous user. Fixes: https://tracker.ceph.com/issues/48001 https://tracker.ceph.com/issues/48382 Original fix by Author: Rafał Wądołowski Signed-off-by: Rafał Wądołowski This fix Signed-off-by: Marcus Watts (cherry picked from commit b5880caa505e2df7ff035537c19a8be3a3a8bb8f) --- diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 93930c414fb3..119bdc04c839 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -2806,7 +2806,12 @@ int RGWHandler_REST_SWIFT::postauth_init(optional_yield y) struct req_init_state* t = &s->init_state; /* XXX Stub this until Swift Auth sets account into URL. */ - s->bucket_tenant = s->user->get_tenant(); + if (g_conf()->rgw_swift_account_in_url + && s->user->get_id().id == RGW_USER_ANON_ID) { + s->bucket_tenant = s->account_name; + } else { + s->bucket_tenant = s->user->get_tenant(); + } s->bucket_name = t->url_bucket; if (!s->object) {