Skip to content

Commit fff21fe

Browse files
committed
* Clarify RBAC rules
* Provide an example for the request and response * Add the note about how to disable the API Signed-off-by: m.nabokikh <[email protected]>
1 parent 81bf29f commit fff21fe

File tree

1 file changed

+63
-5
lines changed
  • keps/sig-auth/3325-self-user-attributes-review-api

1 file changed

+63
-5
lines changed

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

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ The user will hip the endpoint after authentication happens, so all attributes w
8080
This design is inspired by the `*AccessReview` and `TokenReview` APIs.
8181
The endpoint has no input parameters or a `spec` field because only the authentication result is required.
8282

83+
### Request
84+
8385
The structure for building a request:
8486
```go
8587
type SelfUserAttributesReview struct {
@@ -92,9 +94,6 @@ type SelfUserAttributesReview struct {
9294
Status SelfUserAttributesReviewStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
9395
}
9496
```
95-
96-
On receiving a request, the Kubernetes API server fills the status with the user attributes and returns it to the user.
97-
9897
```go
9998
type SelfUserAttributesReviewStatus struct {
10099
// User attributes of the current user.
@@ -110,8 +109,66 @@ type UserInfo struct {
110109
}
111110
```
112111

112+
On receiving a request, the Kubernetes API server fills the status with the user attributes and returns it to the user.
113+
114+
Request URL:
115+
```
116+
GET /apis/authentication.k8s.io/v1alpha1/selfuserattributesreview
117+
```
118+
Response example:
119+
120+
```json
121+
{
122+
"apiVersion": "authentication.k8s.io/v1alpha1",
123+
"kind": "SelfUserAttributesReview",
124+
"status": {
125+
"name": "jane.doe",
126+
"uid": "b6c7cfd4-f166-11ec-8ea0-0242ac120002",
127+
"groups": ["viewers", "editors"],
128+
"extra": {
129+
"provider_id": "token.company.dev"
130+
}
131+
}
132+
}
133+
```
134+
113135
User attributes are known at the moment of accessing the rest API endpoint and can be extracted from the request context.
114136

137+
### RBAC
138+
139+
RBAC rules to grant access to this API should be present in the cluster by default.
140+
It is implied that the `system:basic-user` cluster role will be extended to the following:
141+
```yaml
142+
apiVersion: rbac.authorization.k8s.io/v1
143+
kind: ClusterRole
144+
metadata:
145+
annotations:
146+
rbac.authorization.kubernetes.io/autoupdate: "true"
147+
creationTimestamp: null
148+
labels:
149+
kubernetes.io/bootstrapping: rbac-defaults
150+
name: system:basic-user
151+
rules:
152+
- apiGroups:
153+
- authorization.k8s.io
154+
resources:
155+
- selfsubjectaccessreviews
156+
- selfsubjectrulesreviews
157+
verbs:
158+
- create
159+
- apiGroups:
160+
- authentication.k8s.io
161+
resources:
162+
- selfuserattributesreview
163+
verbs:
164+
- create
165+
```
166+
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+
```
171+
115172
### Test Plan
116173

117174
Unit tests covering:
@@ -141,7 +198,8 @@ Integration test covering:
141198

142199
- Corresponding kubectl command implemented
143200

144-
NOTE: Should not be a part pf [conformance tests](https://git.k8s.io/community/contributors/devel/sig-architecture/conformance-tests.md).
201+
NOTE: Should not be a part of [conformance tests](https://git.k8s.io/community/contributors/devel/sig-architecture/conformance-tests.md).
202+
The fact that a user possesses a token does not necessarily imply the power to know to whom that token belongs.
145203

146204
## Production Readiness Review Questionnaire
147205

@@ -244,7 +302,7 @@ No.
244302
###### Will enabling / using this feature result in introducing new API types?
245303

246304
```
247-
Group: authentication
305+
Group: authentication.k8s.io
248306
Kind: SelfUserAttributesReview
249307
```
250308

0 commit comments

Comments
 (0)