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:
committed by
GitHub
parent
3be82a28d1
commit
542c471584
@@ -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"
|
||||
|
Reference in New Issue
Block a user