Skip to content

rgw/sts: GetCallerIdentity API#63672

Merged
ArbitCode merged 2 commits intoceph:mainfrom
ArbitCode:wip-raja-get-caller-identity
Jul 19, 2025
Merged

rgw/sts: GetCallerIdentity API#63672
ArbitCode merged 2 commits intoceph:mainfrom
ArbitCode:wip-raja-get-caller-identity

Conversation

@ArbitCode
Copy link
Member

@ArbitCode ArbitCode commented Jun 3, 2025

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

@ArbitCode ArbitCode requested a review from a team as a code owner June 3, 2025 09:30
@github-actions github-actions bot added the rgw label Jun 3, 2025
@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from 3926115 to bc257a7 Compare June 3, 2025 12:30
@pritha-srivastava
Copy link
Contributor

@cbodley : we found a test case that creates a role in an account here https://github.com/ceph/s3-tests/blob/master/s3tests_boto3/functional/test_iam.py:test_account_role_create. Is there any test case that tests assume role using cross account access (not tenants).

@cbodley
Copy link
Contributor

cbodley commented Jun 4, 2025

@cbodley : we found a test case that creates a role in an account here https://github.com/ceph/s3-tests/blob/master/s3tests_boto3/functional/test_iam.py:test_account_role_create. Is there any test case that tests assume role using cross account access (not tenants).

the examples i found:
test_cross_account_role_policy_allow
test_account_role_policy_allow_create_bucket
test_account_role_policy_allow_get_role

@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from bc257a7 to 893e852 Compare June 6, 2025 07:37
@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from 893e852 to 74de6af Compare June 13, 2025 19:34
@github-actions github-actions bot added the tests label Jun 13, 2025
@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from 74de6af to 17d4cc1 Compare June 16, 2025 04:15
@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from 17d4cc1 to 405a29d Compare June 16, 2025 06:30
@ArbitCode ArbitCode changed the title rgw/sts: GetCallerIndentity And GetAccountSummary rgw/sts: GetCallerIndentity API Jun 16, 2025
Comment on lines +1147 to +1158
string key = "aws:userid";
string value = user_info.type == TYPE_ROOT ? user_info.account_id : user_info.user_id.id;
s->env.emplace(key, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 but you can please update RemoteApplier too?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, I find user_info is missing,
should I load user_info to check user type?
or without loading user_info can i proceed as I get userid

  const AuthInfo info;
  string key = "aws:userid";
  string value = info.acct_user.id;
  s->env.emplace(key, value);

Copy link
Contributor

Choose a reason for hiding this comment

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

your use of AuthInfo info looks correct to me 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

thank you 👍🏻 pushed new update.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 but you can please update RemoteApplier too?

@cbodley does this really apply to RemoteApplier?

Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't RemoteApplier support all the other interactions with iam policy? RemoteApplier::is_identity() matches policy Principals based on info.acct_user.id, and RemoteApplier::load_acct_info() produces a s->user whose uid comes from info.acct_user

Copy link
Contributor

@pritha-srivastava pritha-srivastava Jun 18, 2025

Choose a reason for hiding this comment

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

yes, but RemoteApplier is meant for Keystone/LDAP users, whereas GetCallerIdentity is mostly for IAM user/root user or roles.

We can add functionality for aws:userid to RemoteApplier, and then we will need to add implementation to its get_caller_indentity() method also? (right now it returns nullopt)

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but RemoteApplier is meant for Keystone/LDAP users, whereas GetCallerIdentity is mostly for IAM user/root user or roles.

this is probably analogous to 'federated users' in sts? but our existing code presents these as normal s3 users

so i think RemoteApplier::get_caller_indentity() would return the same kind of user arn that it matches through is_identity(): "arn:aws:iam::{account id or tentant}:user/{userid}"

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, sounds fine to me. @ArbitCode : add implementation for get_caller_indentity() in RemoteApplier also

Copy link
Member Author

Choose a reason for hiding this comment

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

@pritha-srivastava I added imp for get_caller_identity() in RemoteApplier

@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from a2c84e2 to 570749a Compare June 17, 2025 15:47
@pritha-srivastava
Copy link
Contributor

Overall the PR looks fine to me.

@cbodley
Copy link
Contributor

cbodley commented Jun 18, 2025

Overall the PR looks fine to me.

same! but we should add s3test coverage for this API - at least for LocalApplier and RoleApplier cases

@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from 570749a to f7a3b8c Compare June 23, 2025 04:11
Comment on lines +1046 to +1051
std::unique_ptr<rgw::sal::User> user = driver->get_user(owner_acct_user);
auto user_info = user->get_info();
bool has_account_id = !user_info.account_id.empty();
std::string acct = has_account_id ? user_info.account_id : user_info.user_id.tenant;
if(user_info.type == TYPE_ROOT) {
return rgw::ARN("", "root", acct, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

driver->get_user() just allocates a handle, it doesn't load it from the backend - and we shouldn't try to load it here

RemoteApplier::load_acct_info() will have already loaded this 'shadow user' if it exists, or called RemoteApplier::create_account() to make a new one

if get_caller_identity() needs additional information from the RGWUserInfo, load_acct_info() should stash that in a member variable like we do with the account info:

  // account and policies are loaded by load_acct_info()              
  mutable std::optional<RGWAccountInfo> account;

but if we're just trying to be consistent with what we match in RemoteApplier::is_identity(), this alone should be sufficient:

return rgw::ARN(owner_acct_user.id, "user", owner_acct_user.tenant, true);

Copy link
Member Author

Choose a reason for hiding this comment

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

okay, but there was a example where driver->get_user() was used RemoteApplier::create_account().

Yes, Below is sufficient.

return rgw::ARN(owner_acct_user.id, "user", owner_acct_user.tenant, true);

@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch 3 times, most recently from cf785ae to 97b0bf9 Compare June 27, 2025 07:18
@ArbitCode ArbitCode self-assigned this Jun 28, 2025
@@ -1032,11 +1032,20 @@ auto rgw::auth::RemoteApplier::load_acct_info(const DoutPrefixProvider* dpp) con

void rgw::auth::RemoteApplier::modify_request_state(const DoutPrefixProvider* dpp, req_state* s) const
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't RemoteApplier::get_caller_identity be moved to previous commit?


std::optional<rgw::ARN> rgw::auth::RemoteApplier::get_caller_identity() const
{
return rgw::ARN(owner_acct_user.id, "user", owner_acct_user.tenant, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

@cbodley : are keystone/ldap users created under accounts? from the comments I see handling for global tenant/implicit tenants only.

Copy link
Contributor

Choose a reason for hiding this comment

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

are keystone/ldap users created under accounts?

no, RemoteApplier::create_account() only creates the 'shadow user' - no 'shadow accounts'

though once a shadow user exists, it is possible to migrate that into an account via https://docs.ceph.com/en/latest/radosgw/account/#migrate-an-existing-user-into-an-account

@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch 2 times, most recently from 65e38fa to abd127c Compare July 14, 2025 05:47
@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from abd127c to 64444ba Compare July 14, 2025 05:51
@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from 64444ba to abc3e75 Compare July 16, 2025 14:07
Tracker: https://tracker.ceph.com/issues/72157

Signed-off-by: Raja Sharma <raja@ibm.com>
Tracker: https://tracker.ceph.com/issues/72157

Signed-off-by: Raja Sharma <raja@ibm.com>
@ArbitCode ArbitCode force-pushed the wip-raja-get-caller-identity branch from abc3e75 to a6e6885 Compare July 16, 2025 14:09
@ArbitCode ArbitCode closed this Jul 18, 2025
@ArbitCode ArbitCode reopened this Jul 18, 2025
@ArbitCode ArbitCode merged commit 601989d into ceph:main Jul 19, 2025
21 checks passed
@ArbitCode ArbitCode deleted the wip-raja-get-caller-identity branch July 19, 2025 04:01
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.

3 participants