1
- # KEP-3325: Self user attributes review API
1
+ # KEP-3325: Self subject attributes review API
2
2
3
3
<!-- toc -->
4
4
- [ Release Signoff Checklist] ( #release-signoff-checklist )
@@ -65,15 +65,14 @@ The motivation for this KEP is to reduce obscurity and help users with debugging
65
65
### Goals
66
66
67
67
- Add the API endpoint to get user attributes
68
+ - Add a corresponding kubectl command - ` kubectl auth who-am-i `
68
69
69
70
### Non-Goals
70
71
71
- - Add a corresponding kubectl command
72
-
73
72
## Proposal
74
73
75
- Add a new API endpoint to the ` authentication ` group - ` SelfUserAttributesReview ` .
76
- The user will hip the endpoint after authentication happens, so all attributes will be available to return.
74
+ Add a new API endpoint to the ` authentication ` group - ` SelfSubjectAttributesReview ` .
75
+ The user will hit the endpoint after authentication happens, so all attributes will be available to return.
77
76
78
77
## Design Details
79
78
@@ -84,18 +83,18 @@ The endpoint has no input parameters or a `spec` field because only the authenti
84
83
85
84
The structure for building a request:
86
85
``` go
87
- type SelfUserAttributesReview struct {
86
+ type SelfSubjectAttributesReview struct {
88
87
metav1.TypeMeta ` json:",inline"`
89
88
// Standard list metadata.
90
89
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
91
90
// +optional
92
91
metav1.ObjectMeta ` json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
93
92
// Status is filled in by the server with the user attributes.
94
- Status SelfUserAttributesReviewStatus ` json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
93
+ Status SelfSubjectAttributesReview ` json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
95
94
}
96
95
```
97
96
``` go
98
- type SelfUserAttributesReviewStatus struct {
97
+ type SelfSubjectAttributesReviewStatus struct {
99
98
// User attributes of the current user.
100
99
// +optional
101
100
UserInfo UserInfo ` json:"userInfo,omitempty" protobuf:"bytes,1,opt,name=userInfo"`
@@ -104,23 +103,29 @@ type SelfUserAttributesReviewStatus struct {
104
103
type UserInfo struct {
105
104
Name string ` json:"name" protobuf:"bytes,1,opt,name=name"`
106
105
UID string ` json:"uid" protobuf:"bytes,2,opt,name=uid"`
107
- Groups []string ` json:"groups" protobuf:"bytes,1 ,opt,name=groups"`
108
- Extra map [string ][]string ` json:"extra" protobuf:"bytes,1 ,opt,name=extra"`
106
+ Groups []string ` json:"groups" protobuf:"bytes,3 ,opt,name=groups"`
107
+ Extra map [string ][]string ` json:"extra" protobuf:"bytes,4 ,opt,name=extra"`
109
108
}
110
109
```
111
110
112
111
On receiving a request, the Kubernetes API server fills the status with the user attributes and returns it to the user.
113
112
114
- Request URL:
113
+ Request example (the body would be a ` SelfSubjectAttributesReview ` object):
114
+ ```
115
+ POST /apis/authentication.k8s.io/v1alpha1/selfsubjectattributesreview
115
116
```
116
- GET /apis/authentication.k8s.io/v1alpha1/selfuserattributesreview
117
+ ``` json
118
+ {
119
+ "apiVersion" : " authentication.k8s.io/v1alpha1" ,
120
+ "kind" : " SelfSubjectAttributesReview"
121
+ }
117
122
```
118
123
Response example:
119
124
120
125
``` json
121
126
{
122
127
"apiVersion" : " authentication.k8s.io/v1alpha1" ,
123
- "kind" : " SelfUserAttributesReview " ,
128
+ "kind" : " SelfSubjectAttributesReview " ,
124
129
"status" : {
125
130
"name" : " jane.doe" ,
126
131
"uid" : " b6c7cfd4-f166-11ec-8ea0-0242ac120002" ,
@@ -134,6 +139,10 @@ Response example:
134
139
135
140
User attributes are known at the moment of accessing the rest API endpoint and can be extracted from the request context.
136
141
142
+ NOTE: There are no audiences in requests and responses since the SelfSubjectAttributesReview API is implied to be simple.
143
+ Unlike the TokenReview API works, kube-apiserver will not do additional internal requests.
144
+ Instead, a user will see the exact result of the authentication, which will be extracted from the request context.
145
+
137
146
### RBAC
138
147
139
148
RBAC rules to grant access to this API should be present in the cluster by default.
@@ -144,7 +153,6 @@ kind: ClusterRole
144
153
metadata :
145
154
annotations :
146
155
rbac.authorization.kubernetes.io/autoupdate : " true"
147
- creationTimestamp : null
148
156
labels :
149
157
kubernetes.io/bootstrapping : rbac-defaults
150
158
name : system:basic-user
@@ -159,15 +167,14 @@ rules:
159
167
- apiGroups :
160
168
- authentication.k8s.io
161
169
resources :
162
- - selfuserattributesreview
170
+ - selfsubjectattributesreviews
163
171
verbs :
164
172
- create
165
173
` ` `
166
174
167
- This API is enabled by default and can be disabled by the following kube-apiserver flag (along with the TokenReview API).
168
- ` ` `
169
- --runtime-config=authentication.k8s.io/v1=false
170
- ```
175
+ This API is enabled by default and can be disabled by using one of the following options:
176
+ 1. Deploying a validating admission webhook to the cluster to prevent ` create` requests to the `authentication.k8s.io/selfsubjectattributesreviews`.
177
+ 2. Use the `--runtime-config=authentication.k8s.io/v1=false` kube-apiserver flag to disable the whole API group along with the TokenReview and TokenRequest apis (which does not seem practical).
171
178
172
179
# ## Test Plan
173
180
@@ -185,6 +192,8 @@ Integration test covering:
185
192
186
193
# ## Graduation Criteria
187
194
195
+ ` authentication.k8s.io/v1alpha1` and `authentication.k8s.io/v1beta1` apis will be reintroduced to go through the graduation cycle.
196
+
188
197
# ### Alpha
189
198
190
199
- Feature implemented behind a feature flag
@@ -212,7 +221,7 @@ Pick one of these and delete the rest.
212
221
-->
213
222
214
223
- Feature gate
215
- - Feature gate name: ` SelfUserAttributesReview `
224
+ - Feature gate name : ` SelfSubjectAttributesReview `
216
225
- Components depending on the feature gate :
217
226
- kube-apiserver
218
227
@@ -280,7 +289,7 @@ The feature utilizes core mechanisms of the Kubernetes API server, so the maximu
280
289
281
290
The apiserver_request_* metrics family is helpful to be aware of how many requests to the endpoint are in your cluster and how many of them failed.
282
291
```
283
- {__name__=~"apiserver_request_.*", group="authentication.k8s.io", resource="selfuserattributesreviews "}
292
+ {__ name__ =~ "apiserver_request_ .* ", group="authentication.k8s.io", resource="selfsubjectattributesreview "}
284
293
```
285
294
286
295
###### Are there any missing metrics that would be useful to have to improve observability of this feature?
303
312
304
313
```
305
314
Group: authentication.k8s.io
306
- Kind: SelfUserAttributesReview
315
+ Kind: SelfSubjectAttributesReview
307
316
```
308
317
309
318
###### Will enabling / using this feature result in any new calls to the cloud provider?
0 commit comments