Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add original user/group as extra to the impersonating client used by virtual workspace #3155

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

turkenh
Copy link
Contributor

@turkenh turkenh commented Aug 21, 2024

Summary

We have some validations on our CRDs where we would like to act based on the user information, i.e., we want to allow a specific field to only be initialized by a controller but no one else. The current implementation of build virtual workspaces loses the original user info while doing impersonation.

This PR adds original user and groups information to impersonating client as extra, so that our validator can extract the user/group information and make decisions accordingly.

Related issue(s)

N/A

Release Notes

Add original user/groups information as extra to the impersonating client used by virtual workspace.

@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has signed the DCO. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 21, 2024
@kcp-ci-bot
Copy link
Contributor

Hi @turkenh. Thanks for your PR.

I'm waiting for a kcp-dev member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@turkenh turkenh changed the title ✨ Add original user/group as extra in impersonate for virtual workspace ✨ Add original user/group as extra to the impersonating client used by virtual workspace Aug 21, 2024
// the impersonation config so that the receiver can make
// decisions based on the original user/groups.
impersonationConfig.Impersonate.Extra[OriginalUserAnnotationKey] = []string{user.GetName()}
impersonationConfig.Impersonate.Extra[OriginalGroupsAnnotationKey] = user.GetGroups()
Copy link
Member

Choose a reason for hiding this comment

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

trying to wrap my head around whether we actually want to preserve the original groups as part of the impersonated identity.

What we really want is this:

  • inside of the virtualized workspace this user should have the admin CRUD permissions because the authorization is done by the virtual workspace.
  • outside of the virtualized workspace (e.g. in admission webhooks) we want the actually export owner identity to be effective.

I think we have that partially somewhere called "soft impersonation". Have to double check our thinking there.

🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIR I also believe we should leave groups out. we are really only interested in the person's identity. Groups are per-workspace and not global.

Take this with a grain of salt: it's been a while.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

outside of the virtualized workspace (e.g. in admission webhooks) we want the actually export owner identity to be effective.

Owner identity is both its username and groups. Even we add its groups to the list of groups, it would be partial, permissions might have been granted to its user only. So, on the admission side, I would rather rely on extra where I can find both username/group.

@sttts
Copy link
Member

sttts commented Aug 23, 2024

With #3156 the problem here goes away as the external virtual workspace user is preserved.

@turkenh turkenh force-pushed the impersonate-with-original branch from dd572dd to a6b9309 Compare October 23, 2024 11:11
@sttts
Copy link
Member

sttts commented Oct 23, 2024

/lgtm
/approve
/ok-to-test

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 23, 2024
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: ff7c38f70b4fa926336c4744c77bfa3758356b8b

@kcp-ci-bot kcp-ci-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 23, 2024
@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 23, 2024
@kcp-ci-bot kcp-ci-bot merged commit 7ed3de3 into kcp-dev:main Oct 23, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants