Skip to content

Commit 431b422

Browse files
nabokihmsenj
andcommitted
Apply suggestions from code review
Co-authored-by: Mo Khan <[email protected]> Signed-off-by: m.nabokikh <[email protected]>
1 parent fff21fe commit 431b422

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kep-number: 3225
2+
alpha:
3+
approver: "@enj"

keps/sig-auth/3325-self-user-attributes-review-api/README.md renamed to keps/sig-auth/3325-self-subject-attributes-review-api/README.md

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# KEP-3325: Self user attributes review API
1+
# KEP-3325: Self subject attributes review API
22

33
<!-- toc -->
44
- [Release Signoff Checklist](#release-signoff-checklist)
@@ -65,15 +65,14 @@ The motivation for this KEP is to reduce obscurity and help users with debugging
6565
### Goals
6666

6767
- Add the API endpoint to get user attributes
68+
- Add a corresponding kubectl command - `kubectl auth who-am-i`
6869

6970
### Non-Goals
7071

71-
- Add a corresponding kubectl command
72-
7372
## Proposal
7473

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.
7776

7877
## Design Details
7978

@@ -84,18 +83,18 @@ The endpoint has no input parameters or a `spec` field because only the authenti
8483

8584
The structure for building a request:
8685
```go
87-
type SelfUserAttributesReview struct {
86+
type SelfSubjectAttributesReview struct {
8887
metav1.TypeMeta `json:",inline"`
8988
// Standard list metadata.
9089
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
9190
// +optional
9291
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
9392
// 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"`
9594
}
9695
```
9796
```go
98-
type SelfUserAttributesReviewStatus struct {
97+
type SelfSubjectAttributesReviewStatus struct {
9998
// User attributes of the current user.
10099
// +optional
101100
UserInfo UserInfo `json:"userInfo,omitempty" protobuf:"bytes,1,opt,name=userInfo"`
@@ -104,23 +103,29 @@ type SelfUserAttributesReviewStatus struct {
104103
type UserInfo struct {
105104
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
106105
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"`
109108
}
110109
```
111110

112111
On receiving a request, the Kubernetes API server fills the status with the user attributes and returns it to the user.
113112

114-
Request URL:
113+
Request example (the body would be a `SelfSubjectAttributesReview` object):
114+
```
115+
POST /apis/authentication.k8s.io/v1alpha1/selfsubjectattributesreview
115116
```
116-
GET /apis/authentication.k8s.io/v1alpha1/selfuserattributesreview
117+
```json
118+
{
119+
"apiVersion": "authentication.k8s.io/v1alpha1",
120+
"kind": "SelfSubjectAttributesReview"
121+
}
117122
```
118123
Response example:
119124

120125
```json
121126
{
122127
"apiVersion": "authentication.k8s.io/v1alpha1",
123-
"kind": "SelfUserAttributesReview",
128+
"kind": "SelfSubjectAttributesReview",
124129
"status": {
125130
"name": "jane.doe",
126131
"uid": "b6c7cfd4-f166-11ec-8ea0-0242ac120002",
@@ -134,6 +139,10 @@ Response example:
134139

135140
User attributes are known at the moment of accessing the rest API endpoint and can be extracted from the request context.
136141

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+
137146
### RBAC
138147

139148
RBAC rules to grant access to this API should be present in the cluster by default.
@@ -144,7 +153,6 @@ kind: ClusterRole
144153
metadata:
145154
annotations:
146155
rbac.authorization.kubernetes.io/autoupdate: "true"
147-
creationTimestamp: null
148156
labels:
149157
kubernetes.io/bootstrapping: rbac-defaults
150158
name: system:basic-user
@@ -159,15 +167,14 @@ rules:
159167
- apiGroups:
160168
- authentication.k8s.io
161169
resources:
162-
- selfuserattributesreview
170+
- selfsubjectattributesreviews
163171
verbs:
164172
- create
165173
```
166174
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).
171178

172179
### Test Plan
173180

@@ -185,6 +192,8 @@ Integration test covering:
185192

186193
### Graduation Criteria
187194

195+
`authentication.k8s.io/v1alpha1` and `authentication.k8s.io/v1beta1` apis will be reintroduced to go through the graduation cycle.
196+
188197
#### Alpha
189198

190199
- Feature implemented behind a feature flag
@@ -212,7 +221,7 @@ Pick one of these and delete the rest.
212221
-->
213222

214223
- Feature gate
215-
- Feature gate name: `SelfUserAttributesReview`
224+
- Feature gate name: `SelfSubjectAttributesReview`
216225
- Components depending on the feature gate:
217226
- kube-apiserver
218227

@@ -280,7 +289,7 @@ The feature utilizes core mechanisms of the Kubernetes API server, so the maximu
280289

281290
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.
282291
```
283-
{__name__=~"apiserver_request_.*", group="authentication.k8s.io", resource="selfuserattributesreviews"}
292+
{__name__=~"apiserver_request_.*", group="authentication.k8s.io", resource="selfsubjectattributesreview"}
284293
```
285294
286295
###### Are there any missing metrics that would be useful to have to improve observability of this feature?
@@ -303,7 +312,7 @@ No.
303312
304313
```
305314
Group: authentication.k8s.io
306-
Kind: SelfUserAttributesReview
315+
Kind: SelfSubjectAttributesReview
307316
```
308317
309318
###### Will enabling / using this feature result in any new calls to the cloud provider?

keps/sig-auth/3325-self-user-attributes-review-api/kep.yaml renamed to keps/sig-auth/3325-self-subject-attributes-review-api/kep.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 3325-self-user-attributes-review-api
1+
name: 3325-self-subject-attributes-review-api
22
title: Review attibutes of a current user
33
kep-number: "3325"
44
authors:
@@ -8,7 +8,8 @@ participating-sigs:
88
- sig-auth
99
reviewers:
1010
- "@enj"
11-
- TBD
11+
- "@deads2k"
12+
- "@mikedanese"
1213
approvers:
1314
- TBD
1415
prr-approvers: []
@@ -21,8 +22,8 @@ milestone:
2122
beta: "v1.26"
2223
stable: "v1.27"
2324
feature-gates:
24-
- name: SelfUserAttributesReview
25+
- name: SelfSubjectAttributesReview
2526
components:
2627
- kube-apiserver
27-
disable-supported: false
28+
disable-supported: true
2829
metrics: []

0 commit comments

Comments
 (0)