1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-24 21:08:03 +00:00

Make view link related to GET RBAC permission. (#699)

* Add view link based on GET RBAC permission

* Add tests for view link
This commit is contained in:
Sakala Venkata Krishna Rohit
2025-07-04 14:06:24 -07:00
committed by GitHub
parent 3be82a28d1
commit 542c471584
2 changed files with 83 additions and 8 deletions

View File

@@ -121,15 +121,22 @@ func formatter(summarycache common.SummaryCache, asl accesscontrol.AccessSetLook
return
}
}
hasGet := accessSet.Grants("get", gvr.GroupResource(), resource.APIObject.Namespace(), resource.APIObject.Name())
hasUpdate := accessSet.Grants("update", gvr.GroupResource(), resource.APIObject.Namespace(), resource.APIObject.Name())
hasDelete := accessSet.Grants("delete", gvr.GroupResource(), resource.APIObject.Namespace(), resource.APIObject.Name())
hasPatch := accessSet.Grants("patch", gvr.GroupResource(), resource.APIObject.Namespace(), resource.APIObject.Name())
selfLink := selfLink(gvr, meta)
u := request.URLBuilder.RelativeToRoot(selfLink)
resource.Links["view"] = u
if hasGet {
if attributes.DisallowMethods(resource.Schema)[http.MethodGet] {
resource.Links["view"] = "blocked"
}
} else {
delete(resource.Links, "view")
}
if hasUpdate {
if attributes.DisallowMethods(resource.Schema)[http.MethodPut] {
resource.Links["update"] = "blocked"