Commit 40d66b8e authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #49677 from dims/send-missing-uid-field-during-webhook-authorize

Automatic merge from submit-queue (batch tested with PRs 50103, 49677, 49449, 43586, 48969) Add missing UID in SubjectAccessReviewSpec **What this PR does / why we need it**: WebhookAuthorizer's Authorize should send *all* the information present in the user.Info data structure. We are not sending the UID currently. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note The SubjectAccessReview API in the authorization.k8s.io API group now allows providing the user uid. ```
parents a1aeea8e 9a761b16
...@@ -52583,6 +52583,10 @@ ...@@ -52583,6 +52583,10 @@
"description": "ResourceAuthorizationAttributes describes information for a resource access request", "description": "ResourceAuthorizationAttributes describes information for a resource access request",
"$ref": "#/definitions/io.k8s.api.authorization.v1.ResourceAttributes" "$ref": "#/definitions/io.k8s.api.authorization.v1.ResourceAttributes"
}, },
"uid": {
"description": "UID information about the requesting user.",
"type": "string"
},
"user": { "user": {
"description": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups", "description": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups",
"type": "string" "type": "string"
...@@ -52798,6 +52802,10 @@ ...@@ -52798,6 +52802,10 @@
"description": "ResourceAuthorizationAttributes describes information for a resource access request", "description": "ResourceAuthorizationAttributes describes information for a resource access request",
"$ref": "#/definitions/io.k8s.api.authorization.v1beta1.ResourceAttributes" "$ref": "#/definitions/io.k8s.api.authorization.v1beta1.ResourceAttributes"
}, },
"uid": {
"description": "UID information about the requesting user.",
"type": "string"
},
"user": { "user": {
"description": "User is the user you're testing for. If you specify \"User\" but not \"Group\", then is it interpreted as \"What if User were not a member of any groups", "description": "User is the user you're testing for. If you specify \"User\" but not \"Group\", then is it interpreted as \"What if User were not a member of any groups",
"type": "string" "type": "string"
...@@ -482,6 +482,10 @@ ...@@ -482,6 +482,10 @@
"extra": { "extra": {
"type": "object", "type": "object",
"description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here." "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here."
},
"uid": {
"type": "string",
"description": "UID information about the requesting user."
} }
} }
}, },
......
...@@ -482,6 +482,10 @@ ...@@ -482,6 +482,10 @@
"extra": { "extra": {
"type": "object", "type": "object",
"description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here." "description": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here."
},
"uid": {
"type": "string",
"description": "UID information about the requesting user."
} }
} }
}, },
......
...@@ -1155,6 +1155,13 @@ When an object is created, the system will populate this list with the current s ...@@ -1155,6 +1155,13 @@ When an object is created, the system will populate this list with the current s
<td class="tableblock halign-left valign-top"><p class="tableblock">object</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">object</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uid</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">UID information about the requesting user.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -931,6 +931,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; } ...@@ -931,6 +931,13 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<td class="tableblock halign-left valign-top"><p class="tableblock">object</p></td> <td class="tableblock halign-left valign-top"><p class="tableblock">object</p></td>
<td class="tableblock halign-left valign-top"></td> <td class="tableblock halign-left valign-top"></td>
</tr> </tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">uid</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">UID information about the requesting user.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
</tbody> </tbody>
</table> </table>
......
...@@ -121,6 +121,8 @@ type SubjectAccessReviewSpec struct { ...@@ -121,6 +121,8 @@ type SubjectAccessReviewSpec struct {
// Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer // Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer
// it needs a reflection here. // it needs a reflection here.
Extra map[string]ExtraValue Extra map[string]ExtraValue
// UID information about the requesting user.
UID string
} }
// ExtraValue masks the value so protobuf can generate // ExtraValue masks the value so protobuf can generate
......
...@@ -233,6 +233,7 @@ func autoConvert_v1_SubjectAccessReviewSpec_To_authorization_SubjectAccessReview ...@@ -233,6 +233,7 @@ func autoConvert_v1_SubjectAccessReviewSpec_To_authorization_SubjectAccessReview
out.User = in.User out.User = in.User
out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups)) out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups))
out.Extra = *(*map[string]authorization.ExtraValue)(unsafe.Pointer(&in.Extra)) out.Extra = *(*map[string]authorization.ExtraValue)(unsafe.Pointer(&in.Extra))
out.UID = in.UID
return nil return nil
} }
...@@ -247,6 +248,7 @@ func autoConvert_authorization_SubjectAccessReviewSpec_To_v1_SubjectAccessReview ...@@ -247,6 +248,7 @@ func autoConvert_authorization_SubjectAccessReviewSpec_To_v1_SubjectAccessReview
out.User = in.User out.User = in.User
out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups)) out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups))
out.Extra = *(*map[string]v1.ExtraValue)(unsafe.Pointer(&in.Extra)) out.Extra = *(*map[string]v1.ExtraValue)(unsafe.Pointer(&in.Extra))
out.UID = in.UID
return nil return nil
} }
......
...@@ -233,6 +233,7 @@ func autoConvert_v1beta1_SubjectAccessReviewSpec_To_authorization_SubjectAccessR ...@@ -233,6 +233,7 @@ func autoConvert_v1beta1_SubjectAccessReviewSpec_To_authorization_SubjectAccessR
out.User = in.User out.User = in.User
out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups)) out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups))
out.Extra = *(*map[string]authorization.ExtraValue)(unsafe.Pointer(&in.Extra)) out.Extra = *(*map[string]authorization.ExtraValue)(unsafe.Pointer(&in.Extra))
out.UID = in.UID
return nil return nil
} }
...@@ -247,6 +248,7 @@ func autoConvert_authorization_SubjectAccessReviewSpec_To_v1beta1_SubjectAccessR ...@@ -247,6 +248,7 @@ func autoConvert_authorization_SubjectAccessReviewSpec_To_v1beta1_SubjectAccessR
out.User = in.User out.User = in.User
out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups)) out.Groups = *(*[]string)(unsafe.Pointer(&in.Groups))
out.Extra = *(*map[string]v1beta1.ExtraValue)(unsafe.Pointer(&in.Extra)) out.Extra = *(*map[string]v1beta1.ExtraValue)(unsafe.Pointer(&in.Extra))
out.UID = in.UID
return nil return nil
} }
......
...@@ -120,6 +120,7 @@ func (a *sarApprover) authorize(csr *capi.CertificateSigningRequest, rattrs auth ...@@ -120,6 +120,7 @@ func (a *sarApprover) authorize(csr *capi.CertificateSigningRequest, rattrs auth
sar := &authorization.SubjectAccessReview{ sar := &authorization.SubjectAccessReview{
Spec: authorization.SubjectAccessReviewSpec{ Spec: authorization.SubjectAccessReviewSpec{
User: csr.Spec.Username, User: csr.Spec.Username,
UID: csr.Spec.UID,
Groups: csr.Spec.Groups, Groups: csr.Spec.Groups,
Extra: extra, Extra: extra,
ResourceAttributes: &rattrs, ResourceAttributes: &rattrs,
......
...@@ -64,6 +64,7 @@ func AuthorizationAttributesFrom(spec authorizationapi.SubjectAccessReviewSpec) ...@@ -64,6 +64,7 @@ func AuthorizationAttributesFrom(spec authorizationapi.SubjectAccessReviewSpec)
userToCheck := &user.DefaultInfo{ userToCheck := &user.DefaultInfo{
Name: spec.User, Name: spec.User,
Groups: spec.Groups, Groups: spec.Groups,
UID: spec.UID,
Extra: convertToUserInfoExtra(spec.Extra), Extra: convertToUserInfoExtra(spec.Extra),
} }
......
...@@ -163,6 +163,10 @@ message SubjectAccessReviewSpec { ...@@ -163,6 +163,10 @@ message SubjectAccessReviewSpec {
// it needs a reflection here. // it needs a reflection here.
// +optional // +optional
map<string, ExtraValue> extra = 5; map<string, ExtraValue> extra = 5;
// UID information about the requesting user.
// +optional
optional string uid = 6;
} }
// SubjectAccessReviewStatus // SubjectAccessReviewStatus
......
...@@ -2017,7 +2017,7 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -2017,7 +2017,7 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) {
} else { } else {
yysep2 := !z.EncBinary() yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [5]bool var yyq2 [6]bool
_, _, _ = yysep2, yyq2, yy2arr2 _, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false const yyr2 bool = false
yyq2[0] = x.ResourceAttributes != nil yyq2[0] = x.ResourceAttributes != nil
...@@ -2025,9 +2025,10 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -2025,9 +2025,10 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[2] = x.User != "" yyq2[2] = x.User != ""
yyq2[3] = len(x.Groups) != 0 yyq2[3] = len(x.Groups) != 0
yyq2[4] = len(x.Extra) != 0 yyq2[4] = len(x.Extra) != 0
yyq2[5] = x.UID != ""
var yynn2 int var yynn2 int
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
r.EncodeArrayStart(5) r.EncodeArrayStart(6)
} else { } else {
yynn2 = 0 yynn2 = 0
for _, b := range yyq2 { for _, b := range yyq2 {
...@@ -2176,6 +2177,31 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -2176,6 +2177,31 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) {
} }
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[5] {
yym19 := z.EncBinary()
_ = yym19
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.UID))
}
} else {
r.EncodeString(codecSelferC_UTF81234, "")
}
} else {
if yyq2[5] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("uid"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym20 := z.EncBinary()
_ = yym20
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.UID))
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234) z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else { } else {
z.EncSendContainerState(codecSelfer_containerMapEnd1234) z.EncSendContainerState(codecSelfer_containerMapEnd1234)
...@@ -2294,6 +2320,18 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Dec ...@@ -2294,6 +2320,18 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Dec
h.decMapstringExtraValue((*map[string]ExtraValue)(yyv10), d) h.decMapstringExtraValue((*map[string]ExtraValue)(yyv10), d)
} }
} }
case "uid":
if r.TryDecodeAsNil() {
x.UID = ""
} else {
yyv12 := &x.UID
yym13 := z.DecBinary()
_ = yym13
if false {
} else {
*((*string)(yyv12)) = r.DecodeString()
}
}
default: default:
z.DecStructFieldNotFound(-1, yys3) z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3 } // end switch yys3
...@@ -2305,16 +2343,16 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2305,16 +2343,16 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yyj12 int var yyj14 int
var yyb12 bool var yyb14 bool
var yyhl12 bool = l >= 0 var yyhl14 bool = l >= 0
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2329,13 +2367,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2329,13 +2367,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
} }
x.ResourceAttributes.CodecDecodeSelf(d) x.ResourceAttributes.CodecDecodeSelf(d)
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2350,13 +2388,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2350,13 +2388,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
} }
x.NonResourceAttributes.CodecDecodeSelf(d) x.NonResourceAttributes.CodecDecodeSelf(d)
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2364,21 +2402,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2364,21 +2402,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.User = "" x.User = ""
} else { } else {
yyv15 := &x.User yyv17 := &x.User
yym16 := z.DecBinary() yym18 := z.DecBinary()
_ = yym16 _ = yym18
if false { if false {
} else { } else {
*((*string)(yyv15)) = r.DecodeString() *((*string)(yyv17)) = r.DecodeString()
} }
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2386,21 +2424,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2386,21 +2424,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Groups = nil x.Groups = nil
} else { } else {
yyv17 := &x.Groups yyv19 := &x.Groups
yym18 := z.DecBinary() yym20 := z.DecBinary()
_ = yym18 _ = yym20
if false { if false {
} else { } else {
z.F.DecSliceStringX(yyv17, false, d) z.F.DecSliceStringX(yyv19, false, d)
} }
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2408,26 +2446,48 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2408,26 +2446,48 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Extra = nil x.Extra = nil
} else { } else {
yyv19 := &x.Extra yyv21 := &x.Extra
yym20 := z.DecBinary() yym22 := z.DecBinary()
_ = yym20 _ = yym22
if false { if false {
} else { } else {
h.decMapstringExtraValue((*map[string]ExtraValue)(yyv19), d) h.decMapstringExtraValue((*map[string]ExtraValue)(yyv21), d)
}
}
yyj14++
if yyhl14 {
yyb14 = yyj14 > l
} else {
yyb14 = r.CheckBreak()
}
if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.UID = ""
} else {
yyv23 := &x.UID
yym24 := z.DecBinary()
_ = yym24
if false {
} else {
*((*string)(yyv23)) = r.DecodeString()
} }
} }
for { for {
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
break break
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj12-1, "") z.DecStructFieldNotFound(yyj14-1, "")
} }
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} }
......
...@@ -142,6 +142,9 @@ type SubjectAccessReviewSpec struct { ...@@ -142,6 +142,9 @@ type SubjectAccessReviewSpec struct {
// it needs a reflection here. // it needs a reflection here.
// +optional // +optional
Extra map[string]ExtraValue `json:"extra,omitempty" protobuf:"bytes,5,rep,name=extra"` Extra map[string]ExtraValue `json:"extra,omitempty" protobuf:"bytes,5,rep,name=extra"`
// UID information about the requesting user.
// +optional
UID string `json:"uid,omitempty" protobuf:"bytes,6,opt,name=uid"`
} }
// ExtraValue masks the value so protobuf can generate // ExtraValue masks the value so protobuf can generate
......
...@@ -99,6 +99,7 @@ var map_SubjectAccessReviewSpec = map[string]string{ ...@@ -99,6 +99,7 @@ var map_SubjectAccessReviewSpec = map[string]string{
"user": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups", "user": "User is the user you're testing for. If you specify \"User\" but not \"Groups\", then is it interpreted as \"What if User were not a member of any groups",
"groups": "Groups is the groups you're testing for.", "groups": "Groups is the groups you're testing for.",
"extra": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", "extra": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.",
"uid": "UID information about the requesting user.",
} }
func (SubjectAccessReviewSpec) SwaggerDoc() map[string]string { func (SubjectAccessReviewSpec) SwaggerDoc() map[string]string {
......
...@@ -163,6 +163,10 @@ message SubjectAccessReviewSpec { ...@@ -163,6 +163,10 @@ message SubjectAccessReviewSpec {
// it needs a reflection here. // it needs a reflection here.
// +optional // +optional
map<string, ExtraValue> extra = 5; map<string, ExtraValue> extra = 5;
// UID information about the requesting user.
// +optional
optional string uid = 6;
} }
// SubjectAccessReviewStatus // SubjectAccessReviewStatus
......
...@@ -2017,7 +2017,7 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -2017,7 +2017,7 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) {
} else { } else {
yysep2 := !z.EncBinary() yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [5]bool var yyq2 [6]bool
_, _, _ = yysep2, yyq2, yy2arr2 _, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false const yyr2 bool = false
yyq2[0] = x.ResourceAttributes != nil yyq2[0] = x.ResourceAttributes != nil
...@@ -2025,9 +2025,10 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -2025,9 +2025,10 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[2] = x.User != "" yyq2[2] = x.User != ""
yyq2[3] = len(x.Groups) != 0 yyq2[3] = len(x.Groups) != 0
yyq2[4] = len(x.Extra) != 0 yyq2[4] = len(x.Extra) != 0
yyq2[5] = x.UID != ""
var yynn2 int var yynn2 int
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
r.EncodeArrayStart(5) r.EncodeArrayStart(6)
} else { } else {
yynn2 = 0 yynn2 = 0
for _, b := range yyq2 { for _, b := range yyq2 {
...@@ -2176,6 +2177,31 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -2176,6 +2177,31 @@ func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) {
} }
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[5] {
yym19 := z.EncBinary()
_ = yym19
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.UID))
}
} else {
r.EncodeString(codecSelferC_UTF81234, "")
}
} else {
if yyq2[5] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("uid"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym20 := z.EncBinary()
_ = yym20
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.UID))
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234) z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else { } else {
z.EncSendContainerState(codecSelfer_containerMapEnd1234) z.EncSendContainerState(codecSelfer_containerMapEnd1234)
...@@ -2294,6 +2320,18 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Dec ...@@ -2294,6 +2320,18 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Dec
h.decMapstringExtraValue((*map[string]ExtraValue)(yyv10), d) h.decMapstringExtraValue((*map[string]ExtraValue)(yyv10), d)
} }
} }
case "uid":
if r.TryDecodeAsNil() {
x.UID = ""
} else {
yyv12 := &x.UID
yym13 := z.DecBinary()
_ = yym13
if false {
} else {
*((*string)(yyv12)) = r.DecodeString()
}
}
default: default:
z.DecStructFieldNotFound(-1, yys3) z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3 } // end switch yys3
...@@ -2305,16 +2343,16 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2305,16 +2343,16 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yyj12 int var yyj14 int
var yyb12 bool var yyb14 bool
var yyhl12 bool = l >= 0 var yyhl14 bool = l >= 0
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2329,13 +2367,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2329,13 +2367,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
} }
x.ResourceAttributes.CodecDecodeSelf(d) x.ResourceAttributes.CodecDecodeSelf(d)
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2350,13 +2388,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2350,13 +2388,13 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
} }
x.NonResourceAttributes.CodecDecodeSelf(d) x.NonResourceAttributes.CodecDecodeSelf(d)
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2364,21 +2402,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2364,21 +2402,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.User = "" x.User = ""
} else { } else {
yyv15 := &x.User yyv17 := &x.User
yym16 := z.DecBinary() yym18 := z.DecBinary()
_ = yym16 _ = yym18
if false { if false {
} else { } else {
*((*string)(yyv15)) = r.DecodeString() *((*string)(yyv17)) = r.DecodeString()
} }
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2386,21 +2424,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2386,21 +2424,21 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Groups = nil x.Groups = nil
} else { } else {
yyv17 := &x.Groups yyv19 := &x.Groups
yym18 := z.DecBinary() yym20 := z.DecBinary()
_ = yym18 _ = yym20
if false { if false {
} else { } else {
z.F.DecSliceStringX(yyv17, false, d) z.F.DecSliceStringX(yyv19, false, d)
} }
} }
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -2408,26 +2446,48 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D ...@@ -2408,26 +2446,48 @@ func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.D
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Extra = nil x.Extra = nil
} else { } else {
yyv19 := &x.Extra yyv21 := &x.Extra
yym20 := z.DecBinary() yym22 := z.DecBinary()
_ = yym20 _ = yym22
if false { if false {
} else { } else {
h.decMapstringExtraValue((*map[string]ExtraValue)(yyv19), d) h.decMapstringExtraValue((*map[string]ExtraValue)(yyv21), d)
}
}
yyj14++
if yyhl14 {
yyb14 = yyj14 > l
} else {
yyb14 = r.CheckBreak()
}
if yyb14 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.UID = ""
} else {
yyv23 := &x.UID
yym24 := z.DecBinary()
_ = yym24
if false {
} else {
*((*string)(yyv23)) = r.DecodeString()
} }
} }
for { for {
yyj12++ yyj14++
if yyhl12 { if yyhl14 {
yyb12 = yyj12 > l yyb14 = yyj14 > l
} else { } else {
yyb12 = r.CheckBreak() yyb14 = r.CheckBreak()
} }
if yyb12 { if yyb14 {
break break
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj12-1, "") z.DecStructFieldNotFound(yyj14-1, "")
} }
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} }
......
...@@ -142,6 +142,9 @@ type SubjectAccessReviewSpec struct { ...@@ -142,6 +142,9 @@ type SubjectAccessReviewSpec struct {
// it needs a reflection here. // it needs a reflection here.
// +optional // +optional
Extra map[string]ExtraValue `json:"extra,omitempty" protobuf:"bytes,5,rep,name=extra"` Extra map[string]ExtraValue `json:"extra,omitempty" protobuf:"bytes,5,rep,name=extra"`
// UID information about the requesting user.
// +optional
UID string `json:"uid,omitempty" protobuf:"bytes,6,opt,name=uid"`
} }
// ExtraValue masks the value so protobuf can generate // ExtraValue masks the value so protobuf can generate
......
...@@ -99,6 +99,7 @@ var map_SubjectAccessReviewSpec = map[string]string{ ...@@ -99,6 +99,7 @@ var map_SubjectAccessReviewSpec = map[string]string{
"user": "User is the user you're testing for. If you specify \"User\" but not \"Group\", then is it interpreted as \"What if User were not a member of any groups", "user": "User is the user you're testing for. If you specify \"User\" but not \"Group\", then is it interpreted as \"What if User were not a member of any groups",
"group": "Groups is the groups you're testing for.", "group": "Groups is the groups you're testing for.",
"extra": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.", "extra": "Extra corresponds to the user.Info.GetExtra() method from the authenticator. Since that is input to the authorizer it needs a reflection here.",
"uid": "UID information about the requesting user.",
} }
func (SubjectAccessReviewSpec) SwaggerDoc() map[string]string { func (SubjectAccessReviewSpec) SwaggerDoc() map[string]string {
......
...@@ -144,6 +144,7 @@ func (w *WebhookAuthorizer) Authorize(attr authorizer.Attributes) (authorized bo ...@@ -144,6 +144,7 @@ func (w *WebhookAuthorizer) Authorize(attr authorizer.Attributes) (authorized bo
if user := attr.GetUser(); user != nil { if user := attr.GetUser(); user != nil {
r.Spec = authorization.SubjectAccessReviewSpec{ r.Spec = authorization.SubjectAccessReviewSpec{
User: user.GetName(), User: user.GetName(),
UID: user.GetUID(),
Groups: user.GetGroups(), Groups: user.GetGroups(),
Extra: convertToSARExtra(user.GetExtra()), Extra: convertToSARExtra(user.GetExtra()),
} }
......
...@@ -505,6 +505,7 @@ func TestWebhook(t *testing.T) { ...@@ -505,6 +505,7 @@ func TestWebhook(t *testing.T) {
TypeMeta: expTypeMeta, TypeMeta: expTypeMeta,
Spec: v1beta1.SubjectAccessReviewSpec{ Spec: v1beta1.SubjectAccessReviewSpec{
User: "jane", User: "jane",
UID: "1",
Groups: []string{"group1", "group2"}, Groups: []string{"group1", "group2"},
ResourceAttributes: &v1beta1.ResourceAttributes{ ResourceAttributes: &v1beta1.ResourceAttributes{
Verb: "GET", Verb: "GET",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment