-
Notifications
You must be signed in to change notification settings - Fork 205
[Resource Sharing] Adds resource access management dashboard #2304
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
Merged
DarshitChanpura
merged 22 commits into
opensearch-project:main
from
DarshitChanpura:resource-access-management-dashboard
Sep 29, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b018096
Adds resource access management dashboard
DarshitChanpura a26401f
Updates share button to only be displayed when user can actually share
DarshitChanpura f8cf74e
Adds UI unit tests
DarshitChanpura a795e9d
Adds cypress e2e test for resource-access-management dashboard
DarshitChanpura 1f9af51
Updates cypress workflow
DarshitChanpura 87844c5
Set action version to v8
DarshitChanpura 6b346d9
Adds changelog entry
DarshitChanpura cda24bf
Adds AD plugin to setup and creates sample detector
DarshitChanpura 67fc297
Fix AD dashboard installation
DarshitChanpura 8d5f10b
Adds sample plugin and removes AD completely
DarshitChanpura 4ac3ec4
Fix cypress workflow for resource-access-management
DarshitChanpura c4eb516
Adds explicit dashboard config in workflow
DarshitChanpura 66f7fcd
Corrects file name in cypress workflow
DarshitChanpura de27d12
Merge remote-tracking branch 'upstream/main' into resource-access-man…
DarshitChanpura e6d15df
Addresses fixes to backend api
DarshitChanpura abf6365
Merge branch 'main' into resource-access-management-dashboard
DarshitChanpura 5016034
Fix unit test failure to address backend change for resource-type
DarshitChanpura 0d4dfde
Uses library for normalization of resource types and changes subtitle…
DarshitChanpura 34dc0cd
Adds EuiEmptyPrompt and update api usage
DarshitChanpura cb6d600
Merge remote-tracking branch 'upstream/main' into resource-access-man…
DarshitChanpura a7a91f7
Fix tests
DarshitChanpura 79fbdfa
Change to lodash
DarshitChanpura File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
180 changes: 180 additions & 0 deletions
180
.github/workflows/cypress-test-resource-sharing-enabled-e2e.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| name: E2E Resource Access Management Cypress Tests | ||
|
|
||
| on: [ push, pull_request ] | ||
|
|
||
| env: | ||
| CI: 1 | ||
| # avoid warnings like "tput: No value for $TERM and no -T specified" | ||
| TERM: xterm | ||
| PLUGIN_NAME: opensearch-security | ||
| OPENSEARCH_INITIAL_ADMIN_PASSWORD: myStrongPassword123! | ||
|
|
||
| jobs: | ||
| tests: | ||
| name: Run Cypress resource-access-management tests | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ ubuntu-latest ] | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| steps: | ||
| - name: Checkout Branch | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up JDK 21 for build | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: '21' | ||
|
|
||
| - name: Set env | ||
| run: | | ||
| opensearch_version=$(node -p "require('./package.json').opensearchDashboards.version") | ||
| plugin_version=$(node -p "require('./package.json').version") | ||
| echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV | ||
| echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV | ||
| shell: bash | ||
|
|
||
| - name: Download security plugin and create setup scripts | ||
| uses: ./.github/actions/download-plugin | ||
| with: | ||
| opensearch-version: ${{ env.OPENSEARCH_VERSION }} | ||
| plugin-name: ${{ env.PLUGIN_NAME }} | ||
| plugin-version: ${{ env.PLUGIN_VERSION }} | ||
| download-location: ${{env.PLUGIN_NAME}} | ||
|
|
||
| # build sample-resource-plugin from source (Linux runner) | ||
| - name: Build sample-resource-plugin (server) | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| OSV="${OPENSEARCH_VERSION}" | ||
| # Map 3.2.0[-anything] -> 3.2 | ||
| SEC_REF="$(echo "$OSV" | sed -E 's/^([0-9]+)\.([0-9]+).*/\1.\2/')" | ||
| echo "Derived security repo ref: $SEC_REF (from $OSV)" | ||
|
|
||
| # Prefer branch/tag = X.Y; fall back to main if not found | ||
| if git ls-remote --exit-code --heads https://github.com/opensearch-project/security.git "$SEC_REF" >/dev/null 2>&1 \ | ||
| || git ls-remote --exit-code --tags https://github.com/opensearch-project/security.git "$SEC_REF" >/dev/null 2>&1; then | ||
| REF="$SEC_REF" | ||
| else | ||
| echo "Ref $SEC_REF not found; falling back to main" | ||
| REF="main" | ||
| fi | ||
|
|
||
| git clone --depth 1 --branch "$REF" https://github.com/opensearch-project/security.git security-src | ||
|
|
||
| pushd security-src | ||
| chmod +x ./gradlew | ||
| # Build the sample resource plugin | ||
| ./gradlew :opensearch-sample-resource-plugin:assemble | ||
| ZIP_PATH=$(ls -t sample-resource-plugin/build/distributions/*.zip | head -n1) | ||
| echo "Built sample plugin: $ZIP_PATH" | ||
| cp "$ZIP_PATH" "$GITHUB_WORKSPACE/sample-resource-plugin.zip" | ||
| popd | ||
|
|
||
| echo "SAMPLE_PLUGIN_ZIP=$GITHUB_WORKSPACE/sample-resource-plugin.zip" >> "$GITHUB_ENV" | ||
|
|
||
|
|
||
| - name: Run Opensearch with security + sample resource plugin | ||
| uses: derek-ho/start-opensearch@v8 | ||
| with: | ||
| opensearch-version: ${{ env.OPENSEARCH_VERSION }} | ||
| plugins: "file:$(pwd)/opensearch-security.zip,file:${{ env.SAMPLE_PLUGIN_ZIP }}" | ||
| security-enabled: true | ||
| admin-password: ${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} | ||
| jdk-version: 21 | ||
| resource-sharing-enabled: true | ||
|
|
||
| - name: Check OpenSearch is running | ||
| run: | | ||
| curl https://localhost:9200/_cat/plugins -v -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k | ||
| shell: bash | ||
|
|
||
| # OSD bootstrap | ||
| - name: Setup Dashboard with Security Dashboards Plugin | ||
| uses: derek-ho/setup-opensearch-dashboards@v1 | ||
| with: | ||
| plugin_name: security-dashboards-plugin | ||
|
|
||
| - name: Compile OpenSearch Dashboards | ||
| run: | | ||
| node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers=10 --verbose | ||
| shell: bash | ||
| working-directory: OpenSearch-Dashboards | ||
|
|
||
| - name: Create OpenSearch Dashboards Config | ||
| if: ${{ runner.os == 'Linux' }} | ||
| run: | | ||
| cat << 'EOT' > resource_sharing_config.yml | ||
| server.host: "localhost" | ||
| opensearch.hosts: ["https://localhost:9200"] | ||
| opensearch.ssl.verificationMode: none | ||
| opensearch.username: "kibanaserver" | ||
| opensearch.password: "kibanaserver" | ||
| opensearch.requestHeadersWhitelist: [ authorization,securitytenant ] | ||
| opensearch_security.multitenancy.enabled: true | ||
| opensearch_security.multitenancy.tenants.preferred: ["Private", "Global"] | ||
| opensearch_security.readonly_mode.roles: ["kibana_read_only"] | ||
| opensearch_security.cookie.secure: false | ||
| home.disableWelcomeScreen: true | ||
| EOT | ||
| shell: bash | ||
|
|
||
| - name: Replace opensearch_dashboards.yml | ||
| run: | | ||
| mv resource_sharing_config.yml $GITHUB_WORKSPACE/OpenSearch-Dashboards/config/opensearch_dashboards.yml | ||
| shell: bash | ||
|
|
||
| - name: Run OpenSearch Dashboards | ||
| run: | | ||
| nohup yarn start --no-base-path --no-watch --csp.warnLegacyBrowsers=false | tee dashboard.log & | ||
| shell: bash | ||
| working-directory: OpenSearch-Dashboards | ||
|
|
||
| # Check if OSD is ready with a max timeout of 300 seconds | ||
| - name: Wait for OpenSearch Dashboards (status API) | ||
| shell: bash | ||
| working-directory: OpenSearch-Dashboards | ||
| env: | ||
| OSD_URL: http://localhost:5601 | ||
| OSD_USER: admin | ||
| OSD_PASS: ${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} | ||
| run: | | ||
| set -euo pipefail | ||
| TIMEOUT=300 | ||
| INTERVAL=5 | ||
| end=$((SECONDS + TIMEOUT)) | ||
|
|
||
| echo "Waiting up to ${TIMEOUT}s for ${OSD_URL}/api/status ..." | ||
| while (( SECONDS < end )); do | ||
| out="$(curl -s -k -u "${OSD_USER}:${OSD_PASS}" -H 'kbn-xsrf: true' \ | ||
| -w 'HTTPSTATUS:%{http_code}' "${OSD_URL}/api/status" || true)" | ||
| code="${out##*HTTPSTATUS:}" | ||
| body="${out%HTTPSTATUS:*}" | ||
|
|
||
| # Ready when HTTP 200 AND overall.state === "green" | ||
| if [ "${code:-}" = "200" ] && printf '%s' "${body:-}" | grep -Eiq '"state"[[:space:]]*:[[:space:]]*"green"'; then | ||
| echo "OpenSearch Dashboards status is green (HTTP ${code})." | ||
| exit 0 | ||
| fi | ||
| sleep "${INTERVAL}" | ||
| done | ||
|
|
||
| echo "Timed out after ${TIMEOUT}s waiting for OpenSearch Dashboards status." | ||
| echo "Last 200 lines of dashboard.log:" | ||
| tail -n 200 dashboard.log || true | ||
| exit 1 | ||
|
|
||
|
|
||
| - name: Run Cypress Tests with retry | ||
| uses: Wandalen/wretry.action@v3.3.0 | ||
| with: | ||
| attempt_limit: 5 | ||
| attempt_delay: 2000 | ||
| command: | | ||
| cd ./OpenSearch-Dashboards/plugins/security-dashboards-plugin | ||
| yarn add cypress --save-dev | ||
| eval 'CYPRESS_VERIFY_TIMEOUT=60000 yarn cypress:run --browser chrome --headless --env LOGIN_AS_ADMIN=true --spec "test/cypress/e2e/resource-sharing/resource_access_management.spec.ts"' | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| // stylelint-disable-next-line @osd/stylelint/no_modifying_global_selectors |
112 changes: 112 additions & 0 deletions
112
public/apps/resource-sharing/resource-access-management-app.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import './_index.scss'; | ||
|
|
||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import { I18nProvider } from '@osd/i18n/react'; | ||
|
|
||
| import { | ||
| EuiPage, | ||
| EuiPageBody, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiPageHeader, | ||
| EuiTitle, | ||
| EuiText, | ||
| EuiSpacer, | ||
| } from '@elastic/eui'; | ||
|
|
||
| import { AppMountParameters, CoreStart } from '../../../../../src/core/public'; | ||
| import { DataSourceManagementPluginSetup } from '../../../../../src/plugins/data_source_management/public'; | ||
| import { SecurityPluginStartDependencies, ClientConfigType } from '../../types'; | ||
|
|
||
| import { ResourceSharingPanel } from './resource-sharing-panel'; | ||
| import { buildResourceApi } from '../../utils/resource-sharing-utils'; | ||
|
|
||
| interface Props { | ||
| coreStart: CoreStart; | ||
| depsStart: SecurityPluginStartDependencies; | ||
| params: AppMountParameters; | ||
| config: ClientConfigType; | ||
| redirect: string; | ||
| dataSourceManagement?: DataSourceManagementPluginSetup; | ||
| } | ||
|
|
||
| const ResourceAccessManagementApp: React.FC<Props> = ({ coreStart, depsStart }) => { | ||
| const { | ||
| http, | ||
| notifications: { toasts }, | ||
| } = coreStart; | ||
| const TopNav = depsStart?.navigation?.ui?.TopNavMenu; | ||
|
|
||
| return ( | ||
| <> | ||
| {TopNav ? ( | ||
| <TopNav appName="resource-access" showSearchBar={false} useDefaultBehaviors={true} /> | ||
| ) : null} | ||
| <EuiPage restrictWidth="2000px"> | ||
| <EuiPageBody component="main"> | ||
| <EuiPageHeader> | ||
| <EuiFlexGroup direction="column" gutterSize="xs"> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiTitle size="l"> | ||
| <h1>Resource Access Management</h1> | ||
| </EuiTitle> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiText color="subdued" size="s"> | ||
| Manage sharing for detectors, forecasters, and more. | ||
| </EuiText> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiPageHeader> | ||
|
|
||
| <EuiSpacer size="m" /> | ||
|
|
||
| <ResourceSharingPanel api={buildResourceApi(http)} toasts={toasts} /> | ||
| </EuiPageBody> | ||
| </EuiPage> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export function renderApp( | ||
| coreStart: CoreStart, | ||
| depsStart: SecurityPluginStartDependencies, | ||
| params: AppMountParameters, | ||
| config: ClientConfigType, | ||
| redirect: string, | ||
| dataSourceManagement?: DataSourceManagementPluginSetup | ||
| ) { | ||
| const deps: Props = { | ||
| coreStart, | ||
| depsStart, | ||
| params, | ||
| config, | ||
| dataSourceManagement, | ||
| redirect, | ||
| }; | ||
|
|
||
| ReactDOM.render( | ||
| <I18nProvider> | ||
| <ResourceAccessManagementApp {...deps} /> | ||
| </I18nProvider>, | ||
| params.element | ||
| ); | ||
|
|
||
| return () => ReactDOM.unmountComponentAtNode(params.element); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.