Skip to content

Add permision check for benchmark panel#2108

Open
alexandrudanpop wants to merge 1 commit intomainfrom
feat/benchmarks-rbac
Open

Add permision check for benchmark panel#2108
alexandrudanpop wants to merge 1 commit intomainfrom
feat/benchmarks-rbac

Conversation

@alexandrudanpop
Copy link
Contributor

Fixes OPS-3693

Copilot AI review requested due to automatic review settings March 11, 2026 09:18
@linear
Copy link

linear bot commented Mar 11, 2026

@sonarqubecloud
Copy link

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the secondary left side panel to conditionally show the Benchmark wizard based on user permissions, aligning the Benchmark panel visibility with the app’s authorization model (OPS-3693).

Changes:

  • Introduces useAuthorization-based gating for showing the Benchmark wizard panel content.
  • Adjusts panel visibility/minimize behavior to depend on shouldShowBenchmark rather than the raw isBenchmarkWizardOpen flag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +57 to +58
const shouldShowBenchmark = hasBenchmarkAccess && isBenchmarkWizardOpen;
const shouldShowPanelContent = shouldShowBenchmark || shouldShowAiChat;
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When hasBenchmarkAccess is false but isBenchmarkWizardOpen is true, shouldShowBenchmark becomes false and the wizard is hidden, but the global store state remains "open". Since useOpenBenchmarkWizard can still set isBenchmarkWizardOpen(true) without checking permissions, this can leave the app in an inconsistent state where the benchmark wizard is logically open but invisible. Consider auto-closing (setIsBenchmarkWizardOpen(false)) when access is missing, or enforcing the permission check at the point where the wizard is opened.

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +40
const { checkAccess } = useAuthorization();
const hasBenchmarkAccess =
checkAccess(Permission.WRITE_FLOW) &&
checkAccess(Permission.READ_APP_CONNECTION);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasBenchmarkAccess relies on checkAccess(...), but useAuthorization().checkAccess is currently implemented as return true (packages/react-ui/src/app/common/hooks/authorization-hooks.ts:9-11). As a result, this change does not actually add a permission check and the benchmark panel will still always be shown when isBenchmarkWizardOpen is true. Consider implementing real permission evaluation in useAuthorization (or using an existing authorization source) so this gating is effective.

Copilot uses AI. Check for mistakes.
const { checkAccess } = useAuthorization();
const hasBenchmarkAccess =
checkAccess(Permission.WRITE_FLOW) &&
checkAccess(Permission.READ_APP_CONNECTION);
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The access check uses Permission.READ_APP_CONNECTION, but the Benchmark wizard can open CreateOrEditConnectionDialog (benchmark-wizard.tsx -> ProviderConnectionDialog) which performs connection upsert/patch calls. This flow typically requires Permission.WRITE_APP_CONNECTION (e.g., connection-select.tsx uses WRITE_APP_CONNECTION). Using only READ permission may still expose a wizard UI that cannot successfully complete for users who lack connection write access.

Suggested change
checkAccess(Permission.READ_APP_CONNECTION);
checkAccess(Permission.WRITE_APP_CONNECTION);

Copilot uses AI. Check for mistakes.
@alexandrudanpop alexandrudanpop requested a review from cezudas March 11, 2026 12:32
@cezudas
Copy link
Contributor

cezudas commented Mar 11, 2026

With this change, we are still giving the user the chance to click the Benchmark banner on the homepage.

I suggest we:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants