Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataSource] Restrict to manage data source on the DSM UI #7214

Merged
merged 10 commits into from
Jul 17, 2024

Conversation

yubonluo
Copy link
Contributor

@yubonluo yubonluo commented Jul 10, 2024

Description

Restrict to edit data source on the DSM UI.
manageableBy:

in workspace:
	anyone can not manage data source on the DSM
out of workspace:
	none: anyone can not manage data source on the DSM
	dashboard_admin: only OSD admin can manage source on the DSM
	all: anyone can manage data source on the DSM
in the saved object management page:
         all: anyone can delete/import data source
	dashboard_admin: only OSD admin can delete/import source
	none: anyone can not delete data source

Issues Resolved

#6889

Screenshot

manageableBy="all" or
manageableBy="dashboard_admin" and user is OSD admin
image
image
image

manageableBy="none" or
manageableBy="dashboard_admin" and user is not OSD admin or
user in a workspace
image
image
image

Testing the changes

  1. Clone the latest osd/security-dashboard plugin code and run yarn osd bootstrap
  2. Modify config/opensearch_dashboards.yml
opensearchDashboards.dashboardAdmin.groups: ["dashboard_admin"]
opensearchDashboards.dashboardAdmin.users: ["username"]
workspace.enabled: true 
opensearch.username: "username"
opensearch.password: "password" 
opensearch.ssl.verificationMode: none
savedObjects.permission.enabled: true
data_source.enabled: true
data_source.manageableBy: "all|dashboard_admin|none"
  1. Run yarn start --no-base-path
  2. Operate data source.

Changelog

  • feat: [DataSource] Restrict to edit data source on the DSM UI.

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 67.30%. Comparing base (d67d6ba) to head (c86002d).

Files Patch % Lines
.../data_source_home_panel/data_source_home_panel.tsx 66.66% 0 Missing and 1 partial ⚠️
...rce/components/edit_form/edit_data_source_form.tsx 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7214      +/-   ##
==========================================
- Coverage   67.32%   67.30%   -0.02%     
==========================================
  Files        3500     3500              
  Lines       69225    69232       +7     
  Branches    11276    11282       +6     
==========================================
- Hits        46604    46598       -6     
- Misses      19895    19906      +11     
- Partials     2726     2728       +2     
Flag Coverage Δ
Linux_1 33.25% <ø> (-0.01%) ⬇️
Linux_2 55.30% <ø> (ø)
Linux_3 45.28% <80.00%> (+<0.01%) ⬆️
Windows_1 ?
Windows_2 55.25% <ø> (ø)
Windows_3 45.29% <80.00%> (+0.01%) ⬆️
Windows_4 34.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yubonluo yubonluo changed the title [DataSource] Restrict to edit data source on the DSM UI [DataSource] Restrict to manage data source on the DSM UI Jul 17, 2024
Signed-off-by: yubonluo <[email protected]>
ruanyl
ruanyl previously approved these changes Jul 17, 2024
Signed-off-by: yubonluo <[email protected]>
Comment on lines +93 to +103
core.capabilities.registerSwitcher((request) => {
const { requestWorkspaceId, isDashboardAdmin } = getWorkspaceState(request);
// User can not manage data source in the workspace.
const canManage =
(manageableBy === ManageableBy.All && !requestWorkspaceId) ||
(manageableBy === ManageableBy.DashboardAdmin &&
isDashboardAdmin !== false &&
!requestWorkspaceId);

return { dataSource: { canManage } };
});
Copy link
Member

Choose a reason for hiding this comment

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

Should we move this switcher to workspace?

Comment on lines +180 to +182
{canManageDataSource ? (
<EuiFlexItem grow={false}>{renderDefaultIcon()}</EuiFlexItem>
) : null}
Copy link
Member

@SuZhou-Joe SuZhou-Joe Jul 17, 2024

Choose a reason for hiding this comment

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

Should we restrict user from setting default data source? @ruanyl

@SuZhou-Joe SuZhou-Joe merged commit 41900a0 into opensearch-project:main Jul 17, 2024
71 of 73 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7214-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 41900a0b3eff6b52c250b76d4ca316c141206a6c
# Push it to GitHub
git push --set-upstream origin backport/backport-7214-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-7214-to-2.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7214-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 41900a0b3eff6b52c250b76d4ca316c141206a6c
# Push it to GitHub
git push --set-upstream origin backport/backport-7214-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-7214-to-2.x.

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

Successfully merging this pull request may close these issues.

5 participants