:sparkles: PoC: Implement user warrants
Summary
Needs https://github.com/kcp-dev/kubernetes/pull/145.
From Slack:
:thread: long ago @sur presented a problem (if I remember right) in our current auth model of serviceaccounts only being valid locally, and with that the inability to create workspaces through an APIExport virtual workspace. The steps are these:
- a user U creates a workspace W2 in logicalcluster L1 through an APIExport virtual workspace (that has a permission claim on Workspaces).
- the VW forwards the requests by impersonating its
system:mastersuser with a fakesystem:kcp:adminserviceaccount (S1) for L1 namedsystem:serviceaccount:default:rest. - the forwarded requests hits kcp and kcp authorizes the workspace creation with that S1 serviceaccount. It uses that identity to authorize the use of workspace types. By giving use permission to everybody, this goes through.
- workspace admission sticks S1 as owner on the workspace object, to be used by initialization later.
- the workspace scheduler creates a logicalclusters L2 for W2 and gives S1 admin permissions through a clusterrole+binding.
- the initializers kick in and access the initializer VW for L2 where W2 has been scheduled to. Their requests are impersonated as S1 by the VW.
- these requests hit kcp and the authorizer denies access because S1 is a foreign service account :boom:
Now assume a modified system that
- understands serviceaccounts from other workspaces, but does not give them permissions by default.
- does not use a fake serviceaccount S1 identity to pass through the APIExport VW requests, but preserves the actual controller user and only attaches a warrant that gives the requires access of the claim.
The steps from above would turn into:
- a user U creates a workspace W2 in logicalcluster L1 through an APIExport virtual workspace (that has a permission claim on Workspaces).
- the VW forwards the requests by impersonating its
system:mastersuser as U with a warrant for a fakesystem:kcp:adminserviceaccount (S1) for L1 namedsystem:serviceaccount:default:rest. - the forwarded requests hits kcp and kcp authorizes the workspace creation with that warrant S1 serviceaccount because U is not enough. It uses the U identity to authorize the use of workspace types. ~~By giving use permission to everybody, t~~This goes through.
- workspace admission sticks U with warrant S1 as owner on the workspace object, to be used by initialization later.
- the workspace scheduler creates a logicalclusters L2 for W2 and gives U with warrant S1 admin permissions through a clusterrole+binding.
- the initializers kick in and access the initializer VW for L2 where W2 has been scheduled to. Their requests are impersonated as U with warrant S1 by the VW.
- these requests hit kcp and the authorizer ~denies access because S1 is a foreign service account~ grants access because U with warrant S1 is admin in L2.
Now assume in addition that U is actually a controller serviceaccount S0 in workspace root. Step (7) would :collision: because S0 is foreign for L2. We further modify the system to authenticate serviceaccount as system:kcp:serviceaccount:<logicalcluster>:<ns>:<name> with a warrant for system:serviceaccount:<ns>:<name> restricted to their defining logicalcluster.
Now, U becomes system:kcp:serviceaccount:root:default:controller with warrant system:serviceaccount:default:controller restricted to root. With that (4) becomes
- workspace admission sticks
system:kcp:serviceaccount:root:default:controllerwith warrantsystem:serviceaccount:default:controllerrestricted to root with warrant S1 as owner on the workspace object, to be used by initialization later.
I.e. the user has two warrants. With that (7) becomes:
- these requests hit kcp and the authorizer grants access because
system:kcp:serviceaccount:root:default:controllerwith the TWO warrants including S1 is admin in L2.
Related issue(s)
Fixes #
Release Notes
Pass through original identity of controllers accessing a logical cluster through the APIExport virtual workspace. To get the required permissions, a warrant mechanism is added through user extra fields that attaches secondary user identities purely used for authorization.
In general just a questions. looks good,
/build-image
/build-image
/retest
looks like a flake to me.
/retest /lgtm /approve /hold until @embik gets his question sorted :)
LGTM label has been added.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: mjudeikis
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [mjudeikis]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
/hold cancel