FLPATH-3236 | [Bug] OpenShift Cost Management page accessible without RBAC authorization#2614
FLPATH-3236 | [Bug] OpenShift Cost Management page accessible without RBAC authorization#2614asmasarw wants to merge 1 commit intoredhat-developer:mainfrom
Conversation
Missing ChangesetsThe following package(s) are changed by this PR but do not have a changeset:
See CONTRIBUTING.md for more information about how to add changesets. Changed Packages
|
Review Summary by QodoFix RBAC permission checks by chunking authorization requests
WalkthroughsDescription• Fix RBAC permission checks failing with 413 Payload Too Large error • Implement chunked authorization requests to handle large permission datasets • Improve code readability with modern JavaScript patterns • Add constant for configurable chunk size (250 requests per batch) Diagramflowchart LR
A["Large Permission Request"] -->|Split into chunks| B["authorizeInChunks function"]
B -->|Process 250 at a time| C["permissionsSvc.authorize"]
C -->|Aggregate results| D["Combined Authorization Decisions"]
D -->|Apply RBAC filtering| E["Authorized Clusters & Projects"]
File Changes1. workspaces/cost-management/plugins/cost-management-backend/src/util/checkPermissions.ts
|
Code Review by Qodo
1. Sequential chunk auth too slow
|
|
| for (const chunk of requestChunks) { | ||
| const chunkDecisions = await permissionsSvc.authorize(chunk, { | ||
| credentials, | ||
| }); | ||
| decisions.push(...chunkDecisions); | ||
| } |
There was a problem hiding this comment.
1. Sequential chunk auth too slow 🐞 Bug ➹ Performance
authorizeInChunks awaits each chunk serially, so large permission sets can turn into hundreds/thousands of sequential PermissionsService.authorize calls and make /access endpoints slow enough to time out. This is amplified by the clustersWithoutFullAccess × allProjects cartesian-product request building in filterAuthorizedClustersAndProjects.
Agent Prompt
### Issue description
`authorizeInChunks` performs chunk authorization strictly sequentially. When `filterAuthorizedClustersAndProjects` generates a large number of permission requests (clustersWithoutFullAccess × allProjects), this can produce a very large number of sequential `permissionsSvc.authorize` calls, causing high latency and potential timeouts.
### Issue Context
This PR introduces chunking to avoid 413 payload errors, but chunking alone does not control end-to-end latency at scale.
### Fix Focus Areas
- workspaces/cost-management/plugins/cost-management-backend/src/util/checkPermissions.ts[35-64]
- workspaces/cost-management/plugins/cost-management-backend/src/util/checkPermissions.ts[202-241]
### Suggested fix
1. Add bounded parallelism for chunk authorization (e.g., process chunks with a small concurrency limit like 5–10) so latency is not O(number_of_chunks).
2. If possible, reduce the number of permission checks generated (avoid full cartesian product where upstream data can provide per-cluster project lists; otherwise consider adding a hard cap/guardrail and returning a controlled error/deny when inputs are too large).
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



FLPATH-3236 | [Bug] OpenShift Cost Management page accessible without RBAC authorization
User always can see OpenShift Table Data regardless of what permission he has.
Main issue is that the API returns: 413 Payload Too Large
So the Solution is to call the API in chunks and then to see what is the DICISION - ALLOW or DENY.
UPDATED SCREENSHOT after fixing API Call with No-Permissions Granted.