Skip to content

Commit

Permalink
fix: rbac fix terminal connection on view and edit in helm apps (#3723)
Browse files Browse the repository at this point in the history
* rbac-fix-terminal

* removed unnecessary code
  • Loading branch information
Shivam-nagar23 committed Aug 14, 2023
1 parent 01ff25c commit 20a4708
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion api/k8s/application/k8sApplicationRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ func (handler *K8sApplicationRestHandlerImpl) GetTerminalSession(w http.Response
if resourceRequestBean.AppIdentifier != nil {
// RBAC enforcer applying For Helm App
rbacObject, rbacObject2 := handler.enforcerUtilHelm.GetHelmObjectByClusterIdNamespaceAndAppName(resourceRequestBean.AppIdentifier.ClusterId, resourceRequestBean.AppIdentifier.Namespace, resourceRequestBean.AppIdentifier.ReleaseName)
ok := handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObject) || handler.enforcer.Enforce(token, casbin.ResourceHelmApp, casbin.ActionUpdate, rbacObject2)
ok := handler.enforcer.Enforce(token, casbin.ResourceHelmApp, "*", rbacObject) || handler.enforcer.Enforce(token, casbin.ResourceHelmApp, "*", rbacObject2)

if !ok {
common.WriteJsonResp(w, errors2.New("unauthorized"), nil, http.StatusForbidden)
Expand Down
2 changes: 0 additions & 2 deletions api/restHandler/app/BuildPipelineRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,11 @@ func (handler PipelineConfigRestHandlerImpl) TriggerCiPipeline(w http.ResponseWr
cdPipelineRbacObjects[i] = envObject
}
envRbacResultMap := handler.enforcer.EnforceByEmailInBatch(userEmailId, casbin.ResourceEnvironment, casbin.ActionTrigger, cdPipelineRbacObjects)
i := 0
for _, rbacResultOk := range envRbacResultMap {
if !rbacResultOk {
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusForbidden)
return
}
i++
}
//RBAC ENDS
response := make(map[string]string)
Expand Down

0 comments on commit 20a4708

Please sign in to comment.