@@ -218,7 +218,8 @@ Introduce verbs `impersonate:user-info`, `impersonate:serviceaccount`, `impers
218
218
`impersonate:scheduled-node` :
219
219
- ` impersonate:user-info` limits the impersonator to impersonate users with
220
220
certain 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:`)
222
223
The resource names must be usernames, group names or values in the user extras accoringly.
223
224
- ` impersonate:serviceaccount` that limits the impersonator to impersonate the serviceaccount with
224
225
the certain name/namespace. The resources must be `serviceaccounts`.
@@ -250,7 +251,7 @@ rules:
250
251
apiVersion: rbac.authorization.k8s.io/v1
251
252
kind: ClusterRoleBinding
252
253
metadata:
253
- name: impersonate
254
+ name: constrained- impersonate-only-someUser
254
255
roleRef:
255
256
apiGroup: rbac.authorization.k8s.io
256
257
kind: ClusterRole
@@ -343,13 +344,24 @@ The impersonator does not need the permission for the target action.
343
344
344
345
` ` ` mermaid
345
346
flowchart 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
353
365
` ` `
354
366
355
367
# ## User Stories (Optional)
@@ -659,9 +671,9 @@ spec:
659
671
# ## Auditing
660
672
661
673
Audit 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
665
677
allowed because it impersonates a scheduled node. The specific action such as `list` or `get`
666
678
will not be included in the value given it can be inferred from the request itself.
667
679
@@ -899,7 +911,7 @@ enhancement:
899
911
900
912
On upgrade to a version that enables the feature
901
913
* 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.
903
915
904
916
905
917
* 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
1013
1025
What signals should users be paying attention to when the feature is young
1014
1026
that might indicate a serious problem?
1015
1027
-->
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.
1018
1031
1019
1032
# ##### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
1020
1033
@@ -1024,6 +1037,17 @@ Longer term, we may want to require automated upgrade/rollback tests, but we
1024
1037
are missing a bunch of machinery and tooling and can't do that now.
1025
1038
-->
1026
1039
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
+
1027
1051
# ##### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
1028
1052
1029
1053
<!--
@@ -1168,7 +1192,10 @@ Focusing mostly on:
1168
1192
- periodic API calls to reconcile state (e.g. periodic fetching state,
1169
1193
heartbeats, leader election, etc.)
1170
1194
-->
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.
1172
1199
1173
1200
# ##### Will enabling / using this feature result in introducing new API types?
1174
1201
0 commit comments