]> git.apps.os.sepia.ceph.com Git - ceph.git/log
ceph.git
15 months agorgw/pubsub: use rgw_pubsub_dest::persistent_queue for queue oid
Casey Bodley [Wed, 20 Mar 2024 18:16:15 +0000 (14:16 -0400)]
rgw/pubsub: use rgw_pubsub_dest::persistent_queue for queue oid

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 4bac81a2bc540b110003b7e5a86c8670ea2a2cc8)

15 months agorgw/pubsub: RGWPubSub::remove_topic() removes persistent queue
Casey Bodley [Wed, 20 Mar 2024 18:14:29 +0000 (14:14 -0400)]
rgw/pubsub: RGWPubSub::remove_topic() removes persistent queue

move the persistent queue removal into remove_topic() where we have
access to the topic metadata. avoid trying to remove the queue if it
isn't enabled

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 4c50ad69c37110d42f1f68f6e567cdf5ac506a32)

15 months agorgw/pubsub: rgw_pubsub_dest stores persistent queue oid
Casey Bodley [Wed, 20 Mar 2024 17:57:21 +0000 (13:57 -0400)]
rgw/pubsub: rgw_pubsub_dest stores persistent queue oid

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 3ef1ab3de225a472a37e84d3e8abb6fbfcaddaa2)

15 months agorgw/pubsub: add/remove_persistent_topic() takes topic queue, not name
Casey Bodley [Wed, 20 Mar 2024 17:56:25 +0000 (13:56 -0400)]
rgw/pubsub: add/remove_persistent_topic() takes topic queue, not name

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit ba2566a5fee05d5ab75210f6b2ba0dc6bf683256)

15 months agotest/rgw/pubsub: topic policy doesn't deny access to owner
Casey Bodley [Mon, 18 Mar 2024 14:09:19 +0000 (10:09 -0400)]
test/rgw/pubsub: topic policy doesn't deny access to owner

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a75c3ac8c19870ea58bd195893fdda519106bbf7)

15 months agorgw/pubsub: CreateTopic consults existing topic policy for overwrite
Casey Bodley [Fri, 15 Mar 2024 13:51:36 +0000 (09:51 -0400)]
rgw/pubsub: CreateTopic consults existing topic policy for overwrite

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9b6fe4ac53fb2a1edf190f271c24a2ff9e0442c9)

15 months agorgw/pubsub: fix DeleteTopic permissions
Casey Bodley [Thu, 14 Mar 2024 19:25:02 +0000 (15:25 -0400)]
rgw/pubsub: fix DeleteTopic permissions

non-account users now consult identity policies with
verify_user_permission() when the topic doesn't exist

account users now consult topic policy when it does exist

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 4568b7a0c74404e0d21fcd221070530684de5066)

15 months agorgw/pubsub: CreateTopic consults identity policies when topic doesn't exist
Casey Bodley [Thu, 14 Mar 2024 19:23:12 +0000 (15:23 -0400)]
rgw/pubsub: CreateTopic consults identity policies when topic doesn't exist

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 8896b227226fad92d280e72cd08210685dd445af)

15 months agorgw/pubsub: CreateTopic requires notification_v2 for accounts
Casey Bodley [Thu, 14 Mar 2024 16:04:08 +0000 (12:04 -0400)]
rgw/pubsub: CreateTopic requires notification_v2 for accounts

the account's topic index is only updated by writes/deletes to v2 topic
metadata

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 7d5b826a4acfbc1df6400b8df990ebfed2c64666)

15 months agorgw/pubsub: avoid allocating hash set of strings for attr search
Casey Bodley [Thu, 14 Mar 2024 15:27:55 +0000 (11:27 -0400)]
rgw/pubsub: avoid allocating hash set of strings for attr search

this unordered_set was not static, so we reinitialized it on every call

replace with a constexpr array of string_views so we can search through
sequential memory that's laid out at compile time

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 70fc1eae8f5492dd30a650d25c3fe03c29a60426)

15 months agorgw/pubsub: add ERR_AUTHORIZATION -> AuthorizationError
Casey Bodley [Tue, 12 Mar 2024 23:05:13 +0000 (19:05 -0400)]
rgw/pubsub: add ERR_AUTHORIZATION -> AuthorizationError

sns docs specify AuthorizationError as the 403 error code rather than
s3's AccessDenied:

    https://docs.aws.amazon.com/sns/latest/api/API_CreateTopic.html#API_CreateTopic_Errors

boto3 sns clients can catch this as AuthorizationErrorException

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit b5d5c55b5440fef27a63f43ea1e431ff2a4393d7)

15 months agorgw/pubsub: return 404 NotFound instead of NoSuchKey
Casey Bodley [Tue, 12 Mar 2024 20:26:44 +0000 (16:26 -0400)]
rgw/pubsub: return 404 NotFound instead of NoSuchKey

repurpose the ERR_NOT_FOUND define which was otherwise unused to
customize the error response for sns apis, which return the NotFound
error code instead of NoSuchKey from s3:

    https://docs.aws.amazon.com/sns/latest/api/API_GetTopicAttributes.html#API_GetTopicAttributes_Errors

this allows boto3 sns clients to catch the NotFoundException as expected

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 2cdddad82ecfc80e03a0b6269eee5981ab5b76f0)

15 months agorgw/pubsub: notifications can refer to topics in other accounts/tenants
Casey Bodley [Tue, 12 Mar 2024 23:08:50 +0000 (19:08 -0400)]
rgw/pubsub: notifications can refer to topics in other accounts/tenants

accounts can use topic policy to grant sns:Publish permissions to other
accounts. the PutBucketNotification op should expect TopicArns from
other accounts. the account name from each TopicArn should be used as
the 'tenant' argument for RGWPubSub's constructor so we look for the
topic in the right namespace

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a72975821fe36b411982346254a33771f97abb26)

15 months agorgw/pubsub: customize permissions for account users
Casey Bodley [Tue, 12 Mar 2024 22:57:54 +0000 (18:57 -0400)]
rgw/pubsub: customize permissions for account users

for account users, CreateTopic and ListTopics permissions come from
identity policy alone, ignoring the ownership/policy of existing topics

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 5f64631630765a2130249b23bd54de7d46ce0900)

15 months agorgw/pubsub: when present, use account id instead of tenant
Casey Bodley [Tue, 12 Mar 2024 20:25:58 +0000 (16:25 -0400)]
rgw/pubsub: when present, use account id instead of tenant

RGWPubSub provides topic namespace isolation for tenants by adding
prefixes to rados object names and topic metadata keys. accounts use
this the same way

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit e5f5679616af66044f7f952d7762ac6ab06bdf50)

15 months agorgw/rados: add index for account topics
Casey Bodley [Tue, 12 Mar 2024 19:34:44 +0000 (15:34 -0400)]
rgw/rados: add index for account topics

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 47a18487b27064b7b19e60a6bc1647cbec65a043)

15 months agorgw/pubsub: verify_topic_permission handles cross-account access
Casey Bodley [Sat, 9 Mar 2024 16:09:41 +0000 (11:09 -0500)]
rgw/pubsub: verify_topic_permission handles cross-account access

refactor verify_topic_owner_or_policy() to share the same interface
as similar functions like verify_user/bucket/object_permission()
from rgw_common.cc

in addition to the topic resource policy, this now also consults iam
identity policies like user, group, or role policy

for account users, this now implements cross-account policy evaluation.
this only comes into play for sns:Publish permissions though, because
the topics themselves are scoped to the account

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 86da5739e10b0b1665e5f0b9f375df24b12cc449)

15 months agorgw/auth: rgw_common.h exposes evaluate_iam_policies()
Casey Bodley [Sat, 9 Mar 2024 16:05:10 +0000 (11:05 -0500)]
rgw/auth: rgw_common.h exposes evaluate_iam_policies()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 851161166be710ed7dd85c04e6378dcabb4ef92f)

15 months agorgw/pubsub: do init/validation in init_processing()
Casey Bodley [Sat, 9 Mar 2024 16:08:17 +0000 (11:08 -0500)]
rgw/pubsub: do init/validation in init_processing()

verify_permission() should do permission checks and nothing else!

admin/system users ignore errors from verify_permission() and go on to
call execute() regardless. that means that execute() can't rely on any
initialization that happened during verify_permission(), at risk of
crashing on admin/system requests. it also means that any permission
checks in execute() won't get overridden for admin/system users,
breaking their superuser access

by moving all parameter validation and initialization into
init_processing(), we can prepare all the state that verify_permission()
will need to do it's thing

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 88a35fed3507e37ad191995b014cbd5b089280d0)

15 months agorgw/pubsub: replace log messages with error response
Casey Bodley [Tue, 12 Mar 2024 15:05:11 +0000 (11:05 -0400)]
rgw/pubsub: replace log messages with error response

parameter validation errors should be returned to the client instead of
written to the rgw log

also raises the log level for lots of error messages. very few of them
should require admin attention

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 6fe68c58932b6cda6180be91e8a1b5b465e74711)

15 months agorgw/pubsub: use existing s->bucket for notification ops
Casey Bodley [Tue, 12 Mar 2024 16:46:40 +0000 (12:46 -0400)]
rgw/pubsub: use existing s->bucket for notification ops

s->bucket is already initialized during rgw_build_bucket_policies(),
called from RGWHandler::do_init_permissions()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 537a87d7ae7c88aa4be077d236e74f6e3094b599)

15 months agorgw/pubsub: make v2-specific calls private
Casey Bodley [Fri, 8 Mar 2024 20:01:08 +0000 (15:01 -0500)]
rgw/pubsub: make v2-specific calls private

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 0d61382f4fd52e2e76ab8c02f905c2fb7367c31d)

15 months agoPendingReleaseNotes: announce the rgw user account feature
Casey Bodley [Fri, 15 Mar 2024 14:36:46 +0000 (10:36 -0400)]
PendingReleaseNotes: announce the rgw user account feature

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 339981f8b3b9ce6abf5ccb73fcddc222b1a4228d)

15 months agorgw: reject user tenant that looks like an account id
Casey Bodley [Tue, 12 Mar 2024 22:53:05 +0000 (18:53 -0400)]
rgw: reject user tenant that looks like an account id

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 4180724b5a38d560cddfb6cf04b0baa23915e4a6)

15 months agorgw/auth: log each policy that returns Allow or Deny
Casey Bodley [Wed, 6 Mar 2024 23:37:37 +0000 (18:37 -0500)]
rgw/auth: log each policy that returns Allow or Deny

makes it much easier to debug authorization issues when you can see
exactly which policies led to success/failure

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9057e70d60bf3c22845f2b5e38a2a2633dfbb322)

15 months agorgw/admin: 'user modify' won't change existing account id
Casey Bodley [Wed, 6 Mar 2024 22:43:02 +0000 (17:43 -0500)]
rgw/admin: 'user modify' won't change existing account id

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 750d2d69992fa6fc02d4b7497b5469daa7158ed5)

15 months agorgw/admin: user list accepts --account-id or -name
Casey Bodley [Wed, 6 Mar 2024 22:13:48 +0000 (17:13 -0500)]
rgw/admin: user list accepts --account-id or -name

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 664151ef3866aa95cd1f8a5cbf30856809a4f282)

15 months agorgw: link account root to account user index
Casey Bodley [Tue, 5 Mar 2024 19:28:41 +0000 (14:28 -0500)]
rgw: link account root to account user index

account root users were not linked to the account's user index because
they're not visible to iam apis like ListUsers

but now that 'account rm' is prevented from deleting the account while
users are still present, we want account root users to prevent deletion
too

add root users back to the account user index, but filter them out of
the iam user apis

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit b60335997266932f0a2c26fefc128732c66551a1)

15 months agorgw/auth: expose Identity::get_account()
Casey Bodley [Tue, 5 Mar 2024 18:57:09 +0000 (13:57 -0500)]
rgw/auth: expose Identity::get_account()

now that all identities store an optional account, expose that to the
rest of rgw with get_account(). this cleans up lots of code that
otherwise has to deal with the rgw_owner variant

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 405f93305f0d630a784b2de18a5f263b37362434)

15 months agorgw: validate account user names
Casey Bodley [Mon, 4 Mar 2024 21:46:52 +0000 (16:46 -0500)]
rgw: validate account user names

iam apis have specific requirements for the UserName field. enforce
these requirements for 'user create' and 'user modify' admin ops for
account users

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 119a768ddf6f865d94775bf813c9fa5a25c58956)

15 months agorgw/auth: add account_id and role_id to ops log
Casey Bodley [Thu, 29 Feb 2024 16:12:51 +0000 (11:12 -0500)]
rgw/auth: add account_id and role_id to ops log

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 272a7660ca4ed9b535aaf4607aeaaa46a20e75c7)

15 months agorgw/auth: object ops use new verify_bucket_permission() overload
Casey Bodley [Fri, 1 Mar 2024 14:36:31 +0000 (09:36 -0500)]
rgw/auth: object ops use new verify_bucket_permission() overload

several object operations like PutObject, DeleteObject, etc were handling
policy evaluation manually instead of using the helper functions like
verify_user/bucket/object_permission(), so were missing the cross-policy
evaluation rules for account users

these now call the new 'custom arn' overload of verify_bucket_permission()
for equivalent functionality

the eval_identity_or_session_policies() function is no longer exposed by
rgw_common.h to prevent other ops from adding new logic that doesn't
handle cross-account access

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 315ded47868de276de644315767d9ea2fab9c845)

15 months agorgw/auth: add verify_bucket_permission() overload for custom arn
Casey Bodley [Fri, 1 Mar 2024 00:34:05 +0000 (19:34 -0500)]
rgw/auth: add verify_bucket_permission() overload for custom arn

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 071e89b506437da511538c23ebee0d37c5d37745)

15 months agorgw/auth: WebIdentityApplier doesn't create shadow users for account roles
Casey Bodley [Thu, 29 Feb 2024 18:14:57 +0000 (13:14 -0500)]
rgw/auth: WebIdentityApplier doesn't create shadow users for account roles

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 07cdc65579d8c60399cdde73fddc26c36190fcde)

15 months agorgw/auth: pass user policies into identities
Casey Bodley [Mon, 4 Mar 2024 21:10:17 +0000 (16:10 -0500)]
rgw/auth: pass user policies into identities

loading user policies in rgw_build_bucket_policies() doesn't work for
PostObj requests because we haven't authenticated yet at that point

instead, auth engines load/parse policies when they load the user info.
policies are passed into the auth identities and applied to req_state
via modify_request_state() similar to how RoleApplier handles role
policy

this also moves the load_iam_identity_policies() into rgw_auth.cc for
use by transform_old_authinfo()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 582970a69399d989370bb1ced6e42de724509622)

15 months agorgw/auth: auth engines pass optional account info into identities
Casey Bodley [Thu, 29 Feb 2024 15:56:21 +0000 (10:56 -0500)]
rgw/auth: auth engines pass optional account info into identities

the auth identities need the RGWAccountInfo instead of just the account
id so they can fill in the correct ACLOwner::display_name

this also adds account ownership support to WebIdentityApplier for
AssumeRoleWithWebIdentity

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 8e839ef4be0617b0b881c4ec476c31ec260c5157)

15 months agorgw/rados: load attrs with RadosUser
Casey Bodley [Fri, 1 Mar 2024 17:59:29 +0000 (12:59 -0500)]
rgw/rados: load attrs with RadosUser

when auth looks up a user by key, that should also initialize the user's
attrs so we don't have to load them separately

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit ca69e6879358f781fab7bdbcdcbe3e49fdaee81a)

15 months agorgw: make user email matching case-insensitive
Casey Bodley [Sun, 25 Feb 2024 15:04:44 +0000 (10:04 -0500)]
rgw: make user email matching case-insensitive

handle user emails the same way we do account account emails. store
RGWUserInfo::user_email exactly as the user specified it, but convert
the object name to lower-case for case-insensitive matching

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 947390a342208a8348b030a179bc723d866c0104)

15 months agorgw: deny 'account rm' if not empty
Casey Bodley [Sat, 24 Feb 2024 21:32:53 +0000 (16:32 -0500)]
rgw: deny 'account rm' if not empty

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a4a3cf07cc7eacfdac9870c3b2bb6545b58b3603)

15 months agoqa/rgw: configure sts for all suites that run s3tests
Casey Bodley [Sat, 24 Feb 2024 15:43:14 +0000 (10:43 -0500)]
qa/rgw: configure sts for all suites that run s3tests

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit d853d6dbb939aa5d71ee9dfdee3c47f04a05e27c)

15 months agorgw/iam: Policy takes optional tenant name
Casey Bodley [Thu, 22 Feb 2024 18:16:00 +0000 (13:16 -0500)]
rgw/iam: Policy takes optional tenant name

the iam policy parser takes a tenant string to reject Resource ARNs that
specify resources in other tenants, and prevent wildcards from applying
to other tenants

this is problematic for account users, because cross-account access requires
an identity policy that covers another account's resource. it's the
cross-policy evaluation rules that prevent that from granting access to
things it shouldn't. so for account users, pass a null tenant string to
allow all resource arns

for resource policies, this restriction is unnecessary in the first
place, because the resource policy can only match itself as the resource

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 7d99cbdd09bcad81619b1c4770a663fde2b30563)

15 months agorgw/auth: replace uses of verify_bucket_owner_or_policy()
Casey Bodley [Wed, 21 Feb 2024 23:51:44 +0000 (18:51 -0500)]
rgw/auth: replace uses of verify_bucket_owner_or_policy()

all of the s3 actions that we call verify_bucket_owner_or_policy() for
are already covered by rgw::IAM::op_to_perm(), which maps actions to
acl permissions like RGW_PERM_READ, RGW_PERM_WRITE_ACP etc

that means we can call verify_bucket_permission() as most other bucket
ops do, and rely on its call to verify_bucket_permission_no_policy() to
find the owner's acl grant

i also hadn't implemented the cross-account rules for
verify_bucket_owner_or_policy() yet, and didn't want to

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit b021d0f2f133da6ac9e5972b481094d86802e979)

15 months agorgw/auth: RoleApplier matches paths in role arns
Casey Bodley [Wed, 21 Feb 2024 22:48:20 +0000 (17:48 -0500)]
rgw/auth: RoleApplier matches paths in role arns

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 731bdbc150967bf77a6649d084f0e9a74e6df65b)

15 months agorgw/auth: RoleApplier matches account principals
Casey Bodley [Wed, 21 Feb 2024 20:55:09 +0000 (15:55 -0500)]
rgw/auth: RoleApplier matches account principals

account principals of the form ``arn:aws:iam::123456789012:root``
or ``123456789012`` delegate authority to the account, which means that
it applies to all of the account's users and roles

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit b824bed2a89c31898fbcf772bcbfd326937f7dab)

15 months agorgw/acl: always fill in DisplayName for account owners/grants
Casey Bodley [Wed, 21 Feb 2024 19:04:43 +0000 (14:04 -0500)]
rgw/acl: always fill in DisplayName for account owners/grants

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 1a1f3a0b94e575981cb568c4f8db2f383ab5314f)

15 months agorgw/auth: AssumeRole uses role account as owner
Casey Bodley [Tue, 20 Feb 2024 22:46:06 +0000 (17:46 -0500)]
rgw/auth: AssumeRole uses role account as owner

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit aeecbe14d00cb0da974ff1f5e5505ca220fecd3d)

15 months agorgw/iam: fix DeleteRolePolicyResponse
Casey Bodley [Sun, 18 Feb 2024 14:16:06 +0000 (09:16 -0500)]
rgw/iam: fix DeleteRolePolicyResponse

should only be written on success

was misspelled as DeleteRolePoliciesResponse which boto doesn't like:

botocore.parsers.ResponseParserError: Unable to parse response (junk after document element: line 1, column 159), invalid XML received. Further retries may su
cceed:
b'<DeleteRolePoliciesResponse><ResponseMetadata><RequestId>tx0000082c62511b240fd3d-0065d20f66-4129-a2</RequestId></ResponseMetadata></DeleteRolePoliciesResponse><?xml version="1.0" encoding="UTF-8"?><ErrorResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/"><Error><Code>NoSuchEntity</Code><Message>The requested PolicyName was not found</Message><RequestId>tx0000082c62511b240fd3d-0065d20f66-4129-a2</RequestId><HostId>4129-a2-a</HostId></Error></ErrorResponse>'

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 27b97b81470911d6fdde7378dfb6c0d0ce927a33)

15 months agotest/rgw/multisite: test sync of iam-related metadata
Casey Bodley [Fri, 16 Feb 2024 15:36:21 +0000 (10:36 -0500)]
test/rgw/multisite: test sync of iam-related metadata

use boto3 for iam connection

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 3e99f4b4520a9e1c5452d3b95ec85a84fc0d940a)

15 months agorgw: forward_to_master() passes rgw_owner for effective uid header
Casey Bodley [Mon, 19 Feb 2024 22:31:55 +0000 (17:31 -0500)]
rgw: forward_to_master() passes rgw_owner for effective uid header

when s3 requests get forwarded to the master zone in multisite, we sign
them as the multisite system user because we need to extend the s3
protocol. for example, CreateBucket requests issues by a system user
include an extra response body that encodes the RGWBucketInfo. this way,
the secondary zone can recreate exactly the same bucket that the master
zone did

these forwarded requests include a header like "rgwx-uid: myuserid" to
request that the system user impersonate the given uid. this isn't
necessary for authorization, because the system user overrides
permission checks already. but it's important for resource ownership -
the result of a forwarded CreateBucket request should be a bucket owned
by "myuserid", not the system user

because this "rgwx-uid" header is concerned with ownership, we pass the
string encoding of rgw_owner instead of rgw_user. on the receiving side,
we parse this header in SysReqApplier and override get_aclowner() to
expose it

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 8d50f6103ff481a6ef4bf7c894e1d4329eefcf49)

15 months agorgw/iam: RGWRoleMetadataHandler creates with exclusive=false
Casey Bodley [Sat, 17 Feb 2024 22:58:11 +0000 (17:58 -0500)]
rgw/iam: RGWRoleMetadataHandler creates with exclusive=false

metadata sync needs to be able to overwrite existing role metadata

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 1c3f201af21b526b1295d57bf344bf1b0a73c257)

15 months agorgw/iam: only RGWDeleteRole returns ERR_DELETE_CONFLICT
Casey Bodley [Sat, 17 Feb 2024 22:53:21 +0000 (17:53 -0500)]
rgw/iam: only RGWDeleteRole returns ERR_DELETE_CONFLICT

metadata sync calls RadosRole::delete_obj() after the role is deleted on
the metadata master zone. the role was verified to be empty there, so
metadata sync needs to delete the role anyway

only the iam DeleteRole api should require policies to be removed first

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 51d36c3f60f77f9c2c32d4764ad66c90df67bacd)

15 months agorgw/iam: use retry_raced_role_write() for Role apis
Casey Bodley [Sat, 17 Feb 2024 19:51:11 +0000 (14:51 -0500)]
rgw/iam: use retry_raced_role_write() for Role apis

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 03c30e3e25ca8ec288a01ed4a12e2b5c4226ef67)

15 months agorgw/iam: UserPolicy apis use forward_iam_request_to_master()
Casey Bodley [Sat, 17 Feb 2024 17:48:32 +0000 (12:48 -0500)]
rgw/iam: UserPolicy apis use forward_iam_request_to_master()

fix signature mismatch errors when PutUserPolicy/DeleteUserPolicy are
forwarded in multisite

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 02b90ad3ca7e93ad193483c69adf79539e720a56)

15 months agorgw/iam: use retry_raced_user_write() for User/AccessKey apis
Casey Bodley [Sat, 17 Feb 2024 16:42:12 +0000 (11:42 -0500)]
rgw/iam: use retry_raced_user_write() for User/AccessKey apis

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 91c0a628f0aadd99ae5edb10ba69d2c2bcf29cd1)

15 months agorgw/role: use CreateDate from forwarded CreateRole response
Casey Bodley [Thu, 15 Feb 2024 23:53:16 +0000 (18:53 -0500)]
rgw/role: use CreateDate from forwarded CreateRole response

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 53c4339d7d877d6cbe863a59f0d0dab096e30707)

15 months agorgw: 'user stats' redirects to 'account stats'
Casey Bodley [Thu, 15 Feb 2024 20:00:43 +0000 (15:00 -0500)]
rgw: 'user stats' redirects to 'account stats'

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 333620c8f9ce1e3394e4a7c0d1274601d69dd943)

15 months agorgw: bucket list --uid redirects to account buckets
Casey Bodley [Thu, 15 Feb 2024 19:59:54 +0000 (14:59 -0500)]
rgw: bucket list --uid redirects to account buckets

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 5569f381c7917f7ef139e76559696a5b23c6bf32)

15 months agodoc/radosgw: add awscli examples
Casey Bodley [Wed, 7 Feb 2024 14:44:18 +0000 (09:44 -0500)]
doc/radosgw: add awscli examples

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9b3d18917dcb0375371a603b71aa95e525650137)

15 months agodoc/radosgw: document iam managed policies
Casey Bodley [Fri, 2 Feb 2024 17:47:22 +0000 (12:47 -0500)]
doc/radosgw: document iam managed policies

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit be4ba49ee6e8667db2c6ef499ae3f6c23f058ff6)

15 months agodoc/radosgw: start on iam/account docs
Casey Bodley [Wed, 20 Dec 2023 03:11:05 +0000 (22:11 -0500)]
doc/radosgw: start on iam/account docs

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 019f1a83cbcf08b2ba3894ef6d64a14146ba6293)

15 months agorgw/iam: load and evaluate group policies
Casey Bodley [Sun, 11 Feb 2024 17:24:05 +0000 (12:24 -0500)]
rgw/iam: load and evaluate group policies

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit f660d8b48a2b773e11c2e72a122d1255a889749d)

15 months agorgw: rename iam_user_policies to iam_identity_policies
Casey Bodley [Sun, 11 Feb 2024 17:29:44 +0000 (12:29 -0500)]
rgw: rename iam_user_policies to iam_identity_policies

identity policies can come from iam groups and roles too

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 27fb7178509e1fb8dde132044a0446149ccb6e17)

15 months agorgw/iam: add Group/GroupPolicy APIs
Casey Bodley [Sun, 11 Feb 2024 17:21:45 +0000 (12:21 -0500)]
rgw/iam: add Group/GroupPolicy APIs

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 386276ed00e3619e119bdd18d6fe20b656d2f05d)

15 months agorgw/iam: ListUserPolicies supports Marker/MaxItems
Casey Bodley [Sun, 11 Feb 2024 17:17:14 +0000 (12:17 -0500)]
rgw/iam: ListUserPolicies supports Marker/MaxItems

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 6284745661f25c6db0ba5077237c035002153948)

15 months agorgw/sal: add backend interfaces for group metadata
Casey Bodley [Sun, 11 Feb 2024 17:15:41 +0000 (12:15 -0500)]
rgw/sal: add backend interfaces for group metadata

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 3683a4097fc42f514c5310fc2078d7ef8e0561eb)

15 months agorgw: add struct RGWGroupInfo
Casey Bodley [Fri, 9 Feb 2024 23:05:21 +0000 (18:05 -0500)]
rgw: add struct RGWGroupInfo

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit b0a1fd07ba27ef93e50571ba5dae9abad6c6db72)

15 months agorgw/iam: OpenIDConnectProvider apis support account users
Casey Bodley [Tue, 6 Feb 2024 22:54:12 +0000 (17:54 -0500)]
rgw/iam: OpenIDConnectProvider apis support account users

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 0a28af9f433b39c99d7343c3cc73ee4862036c70)

15 months agorgw/sal: remove virtual class RGWOIDCProvider
Casey Bodley [Tue, 6 Feb 2024 14:32:27 +0000 (09:32 -0500)]
rgw/sal: remove virtual class RGWOIDCProvider

class RGWOIDCProvider was doing a lot of different things, so i've split
out its responsibilities:

* move data members and encoding into new struct RGWOIDCProviderInfo,
  and add ceph-dencoder hooks for regression testing
* remove RGWOIDCProvider class and add load/store/delete/list functions
  to the sal::Driver interface
* rgw_rest_oidc_provider.cc handles most of the parameter validation,
  ARN parsing, and json formatting

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 8c328aa1c7d0f4b934daa08f5361a2fe83d091a6)

15 months agorgw/iam: refactor OIDC ops
Casey Bodley [Mon, 5 Feb 2024 22:49:42 +0000 (17:49 -0500)]
rgw/iam: refactor OIDC ops

rearrange the RGWRESTOp subclasses so that the base RGWRestOIDCProvider
can provide a simple verify_permission() that works the same for all
derived ops

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit fcbc684e44abc0b336682a8f1d3b2ed072a9a359)

15 months agovstart/rgw: add account users for s3-tests
Casey Bodley [Tue, 30 Jan 2024 20:04:37 +0000 (15:04 -0500)]
vstart/rgw: add account users for s3-tests

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit d704540d630f6a8b1e1287e9593139661d95164d)

15 months agoradosgw-admin: add commands for managed policy
Casey Bodley [Mon, 5 Feb 2024 18:57:16 +0000 (13:57 -0500)]
radosgw-admin: add commands for managed policy

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 93522666a0d0ea6f6840107254344fcdf3d89dfc)

15 months agorgw/iam: AttachRolePolicy adds managed role policy
Casey Bodley [Fri, 2 Feb 2024 15:53:14 +0000 (10:53 -0500)]
rgw/iam: AttachRolePolicy adds managed role policy

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 390cdaa45ee923dde2de3e5b8077537c741fe5d9)

15 months agorgw/iam: AttachUserPolicy adds managed user policy
Casey Bodley [Thu, 1 Feb 2024 22:41:08 +0000 (17:41 -0500)]
rgw/iam: AttachUserPolicy adds managed user policy

implement iam apis AttachUserPolicy, DetachUserPolicy, and
ListAttachedUserPolicies to manipulate managed user policy

the set of managed policy ARNs is stored in the user attr
RGW_ATTR_MANAGED_POLICY

for incoming requests, the policies from RGW_ATTR_MANAGED_POLICY are
added to s->iam_user_policies at the same time as RGW_ATTR_USER_POLICY

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit bf64bc624dff5200964cd9763a4d6466edfe07e7)

15 months agorgw/iam: add get_managed_policy() factory function
Casey Bodley [Thu, 1 Feb 2024 19:58:22 +0000 (14:58 -0500)]
rgw/iam: add get_managed_policy() factory function

add definitions for the following managed policy ARNs:

* arn:aws:iam::aws:policy/IAMFullAccess
* arn:aws:iam::aws:policy/IAMReadOnlyAccess
* arn:aws:iam::aws:policy/AmazonSNSFullAccess
* arn:aws:iam::aws:policy/AmazonSNSReadOnlyAccess
* arn:aws:iam::aws:policy/AmazonS3FullAccess
* arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess

factory function get_managed_policy() returns a parsed Policy for the
requested ARN if available

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit ccb6c38d8ea28d337430efc6e660b24896e75f17)

15 months agorgw/iam: add lots of actions needed for managed policies
Casey Bodley [Thu, 1 Feb 2024 19:56:28 +0000 (14:56 -0500)]
rgw/iam: add lots of actions needed for managed policies

in order to parse managed policies, we have to recognize all of the
actions and wildcards they use

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 0fb3ac33937b5873a6cd4c0baadebc1a07f9a218)

15 months agorgw/iam: Policy() takes string instead of bufferlist
Casey Bodley [Thu, 1 Feb 2024 18:10:00 +0000 (13:10 -0500)]
rgw/iam: Policy() takes string instead of bufferlist

the constructor immediately called bufferlist::to_str() to convert it
into a string; just take string so callers don't have to convert it

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit db09c0956a531ad8c026e9b5f924ab32bfb95514)

15 months agorgw: evaluate_iam_policies() handles account root user
Casey Bodley [Thu, 1 Feb 2024 02:51:25 +0000 (21:51 -0500)]
rgw: evaluate_iam_policies() handles account root user

> By default, all requests are implicitly denied with the exception of
> the AWS account root user, which has full access.

the account root user turns an implicit deny from identity policy into
an allow, though other policies can still deny explicitly

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 180f0b7b66a37e4aa5221e68882d009bed686b58)

15 months agorgw/auth: account users match account arns
Casey Bodley [Tue, 30 Jan 2024 23:14:28 +0000 (18:14 -0500)]
rgw/auth: account users match account arns

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 8ce9c0769f0de31ac4a827684aef4f6f441a369f)

15 months agorgw: add cross-account policy evaluation
Casey Bodley [Sat, 27 Jan 2024 20:56:09 +0000 (15:56 -0500)]
rgw: add cross-account policy evaluation

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9b3507c95be6128f348ca0b482646dbd7e709b3c)

15 months agorgw: add generic evaluate_iam_policies()
Casey Bodley [Sat, 27 Jan 2024 20:55:27 +0000 (15:55 -0500)]
rgw: add generic evaluate_iam_policies()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 2a5abafaeee9c3ebe8776db1e6b91031a5b8e088)

15 months agorgw: verify_permission logs acl grants
Casey Bodley [Sat, 27 Jan 2024 19:20:53 +0000 (14:20 -0500)]
rgw: verify_permission logs acl grants

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit be35990b85c6b486434d022c77d87fe49db05f12)

15 months agorgw: adapt verify_user_permission() for account users
Casey Bodley [Sat, 27 Jan 2024 00:02:39 +0000 (19:02 -0500)]
rgw: adapt verify_user_permission() for account users

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit cb81a429fdeca31c3ae28d85d331f2a3052baaa1)

15 months agovstart/rgw: add default config for sts
Casey Bodley [Sat, 27 Jan 2024 00:01:24 +0000 (19:01 -0500)]
vstart/rgw: add default config for sts

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 50411a9bcc90b4dae94ea5f1180c48659e0042ab)

15 months agorgw/role: support Description for Create/Get/UpdateRole
Casey Bodley [Fri, 26 Jan 2024 17:20:53 +0000 (12:20 -0500)]
rgw/role: support Description for Create/Get/UpdateRole

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 44804b1d27c8cd3c0ec57cdd7be0a0deb3f89280)

15 months agorgw/iam: add s3:Get/PutBucketOwnershipControls
Casey Bodley [Fri, 26 Jan 2024 03:04:32 +0000 (22:04 -0500)]
rgw/iam: add s3:Get/PutBucketOwnershipControls

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit f473d28ef0979d535ff1c1d71a880849821cc42b)

15 months agorgw/sal: remove load_account_role_by_name()
Casey Bodley [Tue, 23 Jan 2024 14:47:58 +0000 (09:47 -0500)]
rgw/sal: remove load_account_role_by_name()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit e03e7b2cdc242cd386446b80d5c1d9271868fff5)

15 months agorgw/role: role APIs support account users
Casey Bodley [Tue, 23 Jan 2024 14:22:55 +0000 (09:22 -0500)]
rgw/role: role APIs support account users

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 0571ca82d4c243922389a850d08ed052a6cb66fd)

15 months agorgw/role: separate dump_iam_role() for iam api
Casey Bodley [Sat, 20 Jan 2024 20:16:00 +0000 (15:16 -0500)]
rgw/role: separate dump_iam_role() for iam api

create a new dump_iam_role() for iam api responses that dumps the subset
of role information presented by the apis

RGWRoleInfo::dump() and decode_json() are used by metadata sync to
transfer role metadata between zones, so must contain all information
about the role

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit bf204e982ea5b9e1ad0b6f7a1433404245b2137e)

15 months agorgw/iam: add pagination to ListRoles
Casey Bodley [Mon, 15 Jan 2024 17:35:58 +0000 (12:35 -0500)]
rgw/iam: add pagination to ListRoles

rename sal::Driver::get_roles() to list_roles() and add pagination
support for the RGWListRoles op and 'radosgw-admin role list'

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 70d63dac461ee3d31d8420ed0628b8a94851f85f)

15 months agorgw/iam: enable Role apis against account users
Casey Bodley [Mon, 15 Jan 2024 16:11:35 +0000 (11:11 -0500)]
rgw/iam: enable Role apis against account users

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 8703b7aaf556846b144a23bf74c1621309ff7192)

15 months agorgw/iam: role apis override init_processing/verify_permission
Casey Bodley [Mon, 15 Jan 2024 01:36:28 +0000 (20:36 -0500)]
rgw/iam: role apis override init_processing/verify_permission

replace get_params() with init_processing() override which runs before
verify_permission(). use this to validate request parameters and load
the existing role if necessary. simplify verify_permission() by
forwarding to RGWRESTOp::verify_permission() which calls check_caps()

simplify inheritence hierarchy by taking cap perm and iam action as
constructor arguments

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 46053028cabc8e089401363b15d81890dc9fb8e8)

15 months agorgw/iam: split RGWRestRole member variables
Casey Bodley [Sun, 14 Jan 2024 21:32:19 +0000 (16:32 -0500)]
rgw/iam: split RGWRestRole member variables

move member variables into the subclasses they're needed for

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 5b8fcf776cfc6dff0845bc4571304fe3b4dd3e7b)

15 months agorgw/iam: RGWUntagRole uses lower/upper bounds for iteration
Casey Bodley [Sun, 14 Jan 2024 21:16:50 +0000 (16:16 -0500)]
rgw/iam: RGWUntagRole uses lower/upper bounds for iteration

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit fd96b15e478855e5950248fbdc9a7736488a6bf5)

15 months agorgw/iam: RGWRestRole::parse_tags() as free function
Casey Bodley [Sun, 14 Jan 2024 21:00:20 +0000 (16:00 -0500)]
rgw/iam: RGWRestRole::parse_tags() as free function

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit b61169e031604e861c852dc8d2bb24d7d7efef1b)

15 months agorgw/iam: AccessKey apis call forward_iam_request_to_master()
Casey Bodley [Sun, 14 Jan 2024 19:06:26 +0000 (14:06 -0500)]
rgw/iam: AccessKey apis call forward_iam_request_to_master()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 896681fcd020636bd70c8fc718575a6a2805f738)

15 months agorgw/iam: User apis call forward_iam_request_to_master()
Casey Bodley [Sun, 14 Jan 2024 18:52:58 +0000 (13:52 -0500)]
rgw/iam: User apis call forward_iam_request_to_master()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit c2364c17ec5c2afc033cd39de9b9b3bd68083d18)

15 months agorgw: move forward_iam_request_to_master() to rgw_rest_iam.*
Casey Bodley [Sun, 14 Jan 2024 18:03:49 +0000 (13:03 -0500)]
rgw: move forward_iam_request_to_master() to rgw_rest_iam.*

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit df8758f723905f3fa7434f547ba44bc495bcf214)

15 months agorgw/rest: enable iam UserPolicy apis against account users
Casey Bodley [Thu, 11 Jan 2024 23:45:55 +0000 (18:45 -0500)]
rgw/rest: enable iam UserPolicy apis against account users

when the authenticated user belongs to an account:
* operate only on that account's users
* match UserName to user's display_name instead of user_id

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 3841906eeb2e64a07c74b746ffe79649627b8d55)

15 months agorgw/rest: simplify RGWRestUserPolicy hierarchy
Casey Bodley [Thu, 11 Jan 2024 23:41:03 +0000 (18:41 -0500)]
rgw/rest: simplify RGWRestUserPolicy hierarchy

base class constructor takes `uint64_t action` instead of overriding
the virtual `get_op()` on each subclass

constructor takes `uint32_t perm` instead of deriving separate base
classes RGWUserPolicyRead/Write for check_caps() permission

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 6d61c397a84efde7e99ed7c00d2216990f0d9884)

15 months agorgw/rest: iam user policy api cleanup
Casey Bodley [Thu, 11 Jan 2024 23:06:36 +0000 (18:06 -0500)]
rgw/rest: iam user policy api cleanup

make get_params() virtual and protected. base class always validates
UserName

add common init_processing() function that calls get_params() and loads
the user by UserName. this step happens before verify_permission()

set s->err.message in several error paths

add the xmlns="https://iam.amazonaws.com/doc/2010-05-08/" part to the
responses

return ERR_LIMIT_EXCEEDED instead of ERR_INVALID_REQUEST when
RGWPutUserPolicy exceeds the policy limit

where RGW_ATTR_USER_POLICY is missing, treat it the same way we treat an
empty map of policies. this avoids separate error paths

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 93428aa6e49da8cdd602d761eaff693449bf57f2)