diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go index 007efe9d884..eac752573ca 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors.go @@ -67,18 +67,15 @@ func forbiddenMessage(attributes authorizer.Attributes) string { } resource := attributes.GetResource() - if group := attributes.GetAPIGroup(); len(group) > 0 { - resource = resource + "." + group - } if subresource := attributes.GetSubresource(); len(subresource) > 0 { resource = resource + "/" + subresource } if ns := attributes.GetNamespace(); len(ns) > 0 { - return fmt.Sprintf("User %q cannot %s %s in the namespace %q", username, attributes.GetVerb(), resource, ns) + return fmt.Sprintf("User %q cannot %s resource %q in API group %q in the namespace %q", username, attributes.GetVerb(), resource, attributes.GetAPIGroup(), ns) } - return fmt.Sprintf("User %q cannot %s %s at the cluster scope", username, attributes.GetVerb(), resource) + return fmt.Sprintf("User %q cannot %s resource %q in API group %q at the cluster scope", username, attributes.GetVerb(), resource, attributes.GetAPIGroup()) } // InternalError renders a simple internal error diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go index 0dcf7adf97f..846e76638dc 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/errors_test.go @@ -72,12 +72,12 @@ func TestForbidden(t *testing.T) { `, authorizer.AttributesRecord{User: u, Verb: "GET", Path: "/whatever"}, "", "application/json"}, {`{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"forbidden: User \"NAME\" cannot GET path \"/\u0026lt;script\u0026gt;\"","reason":"Forbidden","details":{},"code":403} `, authorizer.AttributesRecord{User: u, Verb: "GET", Path: "/