diff --git a/plugin/pkg/auth/authorizer/webhook/webhook.go b/plugin/pkg/auth/authorizer/webhook/webhook.go index 9b7e57addb6..6cce9ffe47b 100644 --- a/plugin/pkg/auth/authorizer/webhook/webhook.go +++ b/plugin/pkg/auth/authorizer/webhook/webhook.go @@ -151,10 +151,13 @@ func (w *WebhookAuthorizer) Authorize(attr authorizer.Attributes) (err error) { } if attr.IsResourceRequest() { r.Spec.ResourceAttributes = &v1beta1.ResourceAttributes{ - Namespace: attr.GetNamespace(), - Verb: attr.GetVerb(), - Group: attr.GetAPIGroup(), - Resource: attr.GetResource(), + Namespace: attr.GetNamespace(), + Verb: attr.GetVerb(), + Group: attr.GetAPIGroup(), + Version: attr.GetAPIVersion(), + Resource: attr.GetResource(), + Subresource: attr.GetSubresource(), + Name: attr.GetName(), } } else { r.Spec.NonResourceAttributes = &v1beta1.NonResourceAttributes{ diff --git a/plugin/pkg/auth/authorizer/webhook/webhook_test.go b/plugin/pkg/auth/authorizer/webhook/webhook_test.go index 56da9d9813a..5629fa2ba75 100644 --- a/plugin/pkg/auth/authorizer/webhook/webhook_test.go +++ b/plugin/pkg/auth/authorizer/webhook/webhook_test.go @@ -435,7 +435,10 @@ func TestWebhook(t *testing.T) { Verb: "GET", Namespace: "kittensandponies", APIGroup: "group3", + APIVersion: "v7beta3", Resource: "pods", + Subresource: "proxy", + Name: "my-pod", ResourceRequest: true, Path: "/foo", }, @@ -445,10 +448,13 @@ func TestWebhook(t *testing.T) { User: "jane", Groups: []string{"group1", "group2"}, ResourceAttributes: &v1beta1.ResourceAttributes{ - Verb: "GET", - Namespace: "kittensandponies", - Group: "group3", - Resource: "pods", + Verb: "GET", + Namespace: "kittensandponies", + Group: "group3", + Version: "v7beta3", + Resource: "pods", + Subresource: "proxy", + Name: "my-pod", }, }, },