@@ -218,7 +218,8 @@ Introduce verbs `impersonate:user-info`, `impersonate:serviceaccount`, `impers
218218`impersonate:scheduled-node` :
219219- ` impersonate:user-info` limits the impersonator to impersonate users with
220220certain names/groups/userextras. The resources must be `users`/`groups`/`userextras`/`uids`.
221- and the user must not be a node (username with a prefix of `system:nodes`)
221+ and the user must not be a node (username with a prefix of `system:node:`) and the user must
222+ not be a service account (username with a prefix of `system:serviceaccount:`)
222223The resource names must be usernames, group names or values in the user extras accoringly.
223224- ` impersonate:serviceaccount` that limits the impersonator to impersonate the serviceaccount with
224225the certain name/namespace. The resources must be `serviceaccounts`.
@@ -250,7 +251,7 @@ rules:
250251apiVersion: rbac.authorization.k8s.io/v1
251252kind: ClusterRoleBinding
252253metadata:
253- name: impersonate
254+ name: constrained- impersonate-only-someUser
254255roleRef:
255256 apiGroup: rbac.authorization.k8s.io
256257 kind: ClusterRole
@@ -343,13 +344,24 @@ The impersonator does not need the permission for the target action.
343344
344345` ` ` mermaid
345346flowchart TD
346- A[receive request] -->|feature enabled| B{Verify the requester has the permission to impersonate with the scope of the user}
347- B --> |yes| C{Verify the requester has the permission to impersonate the target action}
348- C -->|yes| D[Allow]
349- A -->|feature disable| E{Verify the requester has the legacy impersonate permission}
350- E -->|yes| D
351- B -->|no| E
352- C -->|no| E
347+ A[receive request] -->|feature enabled| B{Identify the target user via impersonation header}
348+ B --> |Impersonate-User has the prefix of system:node|C{The requester is on the same node}
349+ C --> |yes| D{Requester is authorized with impersonate:scheduled-node}
350+ C --> |no| E{Requester is authorized with impersonate:node}
351+ D --> |yes| F{Requester is authorized to impersonate the target action}
352+ D --> |no| E
353+ E --> |yes| F
354+ E --> |no| H
355+ F -->|yes| G[Allow]
356+ A -->|feature disable| H{Requester has the legacy impersonate permission}
357+ H -->|yes| G
358+ F -->|no| H
359+ B --> |Impersonate-User has the prefix of system:serviceaccount| I{Requester is authorized with impersonate:serviceaccount}
360+ I --> |yes| F
361+ I --> |no| H
362+ B --> J{Requester is authorized with impersonate:user-info}
363+ J --> |yes|F
364+ J --> |no|H
353365` ` `
354366
355367# ## User Stories (Optional)
@@ -659,9 +671,9 @@ spec:
659671# ## Auditing
660672
661673Audit events already contain the `impersonatedUser` field to denote if impersonation was used.
662- To record the reason why the impersonation is allowed, an annotation `allowed-impersonation-verbs ` will
663- be added. The value will be the impersonation related verbs. For example,
664- `allowed-impersonation-verbs : impersonate:scheduled-node` indicates that the impersonation request is
674+ To record the reason why the impersonation is allowed, a field `impersonationConstraint ` will
675+ be added in the `impersonatedUser` . The value will be the impersonation related verbs. For example,
676+ ` impersonate:scheduled-node` indicates that the impersonation request is
665677allowed because it impersonates a scheduled node. The specific action such as `list` or `get`
666678will not be included in the value given it can be inferred from the request itself.
667679
@@ -899,7 +911,7 @@ enhancement:
899911
900912On upgrade to a version that enables the feature
901913* the previous impersonator with impersonate permission will still work, but it is highly
902- recommanded to use the new permissions with less privilege.
914+ recommended to use the new permissions with less privilege.
903915
904916
905917* authorization webhooks needs to recognize the verb with prefix of `impersonate-on:` and
@@ -1013,8 +1025,9 @@ be authorized to impersonate. Impersonator will need to have the unscoped impers
10131025What signals should users be paying attention to when the feature is young
10141026that might indicate a serious problem?
10151027-->
1016-
1017- Authz latency for impersonation is too long.
1028+ authorization_attempts_total shows greatly increased number.
1029+ authorization_duration_seconds_bucket shows greatly increased number of request
1030+ with longer duration.
10181031
10191032# ##### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
10201033
@@ -1024,6 +1037,17 @@ Longer term, we may want to require automated upgrade/rollback tests, but we
10241037are missing a bunch of machinery and tooling and can't do that now.
10251038-->
10261039
1040+ Integration tests cover feature gate disablement and enablement.
1041+
1042+ Manual tests to cover upgrade->downgrade->upgrade :
1043+ 1. Deploy k8s 1.33
1044+ 2. create impersonate permissions for user bob and verify impersonation
1045+ 3. Upgrade to 1.34 and enable the `ConstrainedImpersonation` featuregate.
1046+ 4. Verify impersonation of user bob.
1047+ 5. create permission for constrained impersonation for user alice and verify impersonation
1048+ 6. Downgrade to 1.33. Verify impersonation for user bob and alice. Alice would not be able
1049+ to impersonate while bob is able to.
1050+
10271051# ##### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
10281052
10291053<!--
@@ -1168,7 +1192,10 @@ Focusing mostly on:
11681192 - periodic API calls to reconcile state (e.g. periodic fetching state,
11691193 heartbeats, leader election, etc.)
11701194-->
1171- No.
1195+ Yes, enabling the feature will result in two additional SAR checks when kube-apiserver
1196+ receives an impersonation request.
1197+ - A SAR request to check if the impersonator is authorized to impersonate the target user.
1198+ - A SAR request to check if the impersonater is authorized to perform the action via impersonation.
11721199
11731200# ##### Will enabling / using this feature result in introducing new API types?
11741201
0 commit comments