Skip to content

Commit e02f2be

Browse files
Merge pull request #7016 from devtron-labs/fix/api-token-webhook-rbac-7013
fix(security): enforce caller RBAC in API token webhook endpoint
2 parents b4efce2 + 5d2c905 commit e02f2be

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎api/apiToken/ApiTokenRestHandler.go‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,15 @@ func (impl ApiTokenRestHandlerImpl) GetAllApiTokensForWebhook(w http.ResponseWri
220220
return
221221
}
222222

223-
// handle super-admin RBAC
223+
// handle super-admin RBAC - this endpoint's only caller is the dashboard's
224+
// webhook config modal, which is itself super-admin-only, so gate the
225+
// whole endpoint the same way the other handlers in this file do.
226+
token := r.Header.Get("token")
227+
if !impl.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionUpdate, "*") {
228+
common.WriteJsonResp(w, errors.New("unauthorized"), nil, http.StatusForbidden)
229+
return
230+
}
231+
224232
v := r.URL.Query()
225233
projectName := v.Get("projectName")
226234
environmentName := v.Get("environmentName")

0 commit comments

Comments
 (0)