feat!: issue access keys as admin via targetUser - #3
Merged
Conversation
RustFS has always accepted `targetUser` on add-service-account, but rc-core did not expose the field, so the operator authenticated *as the owning user* to mint that user's keys. That forced every AccessKey to carry the user's password and every owning user's policy to grant admin:CreateServiceAccount / ListServiceAccounts / RemoveServiceAccount over itself — a requirement that is easy to miss and fails with a bare AccessDenied when you do. rustfs/cli#340 was fixed by rustfs/cli#352 and released in rc-core 0.1.32, which adds `target_user` to CreateServiceAccountRequest. Use it: keys are now created, inspected and revoked with the admin credential. BREAKING CHANGE: `AccessKey.spec.passwordRef` and the chart's `accessKeys[].passwordFromUser` / `passwordRef` are removed. The field is kept in the CRD schema purely so a stale manifest is rejected as a spec error instead of being silently pruned; the chart fails at render time. Drop those fields, and drop the three admin:*ServiceAccount grants from the owning user's policy unless something else needs them. The operator's connection must now hold RustFS root: the server's guard is `owner || target_user == req_user || target_user == req_parent_user`, so only an owner may parent a key to another user. This is deliberate upstream (GHSA-5354) — admin:CreateServiceAccount controls whether a caller can create keys, not for whom. Verified against a live RustFS 1.0.0-beta.12: creating a service account with targetUser as the admin credential parents it to the named user with no password involved, and both info and delete work the same way. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxBhmDG53GRf1vdanvsZBS
The two container-backed suites are behind cargo features, so a plain `cargo clippy --all-targets` missed them; CI caught it. Both now drop the password arguments, and both drop the admin:*ServiceAccount grants from the test user's policy — their absence is part of what the suites assert. The RustFS integration test also checks `parent_user == "it-user"` on the issued key, which is the actual behaviour targetUser buys. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SxBhmDG53GRf1vdanvsZBS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream rustfs/cli#340 — the one I filed about
targetUserbeing unreachable from the client — was fixed by #352 and released in rc-core 0.1.32. This adopts it.What changes
Access keys are now created, inspected and revoked with the operator's admin credential, naming the owner via
targetUser. Previously the operator built a second client authenticated as the owning user.That removes two long-standing warts:
AccessKeyno longer needs the user's password (passwordRef/ chartpasswordFromUser)admin:CreateServiceAccount/ListServiceAccounts/RemoveServiceAccountover itself — a requirement that was easy to miss and surfaced only as a bareAccessDeniedBreaking
AccessKey.spec.passwordRefand the chart'saccessKeys[].passwordFromUser/passwordRefare gone. The field stays in the CRD schema only so a stale manifest is rejected as a spec error rather than silently pruned by the API server; the chart fails at render time with the same guidance.Migration: delete those fields, and drop the three
admin:*ServiceAccountgrants from the owning user's policy unless something else needs them.New requirement: the connection must hold RustFS root
The server's guard is
owner || target_user == req_user || target_user == req_parent_user, so only an owner credential may parent a key to another user. A scoped admin now getsservice account parent is outside requester scope.This is deliberate upstream (GHSA-5354):
admin:CreateServiceAccountcontrols whether a caller can create keys, not for whom, and without the guard any holder of that action could mint a root-parented key and escalate. Documented indocs/iam-model.md.Verification
Against a live RustFS
1.0.0-beta.12, using the admin credential:info-service-accountfor another user's key also returns200with the rightparentUser, so all three paths the operator needs work admin-side.24 unit tests pass (one new, covering the
passwordRefrejection);chart-tests.shpasses; clippy/fmt/actionlint clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01SxBhmDG53GRf1vdanvsZBS