opensearch-project / security-dashboards-plugin

🔐 Manage your internal users, roles, access control, and audit logs from OpenSearch Dashboards
https://opensearch.org/docs/latest/security-plugin/index/
Apache License 2.0
66 stars 148 forks source link

[BUG] [MDS] No available datasources or illegal datasource crashes the plugin #1934

Closed derek-ho closed 3 weeks ago

derek-ho commented 2 months ago

What is the bug? When no datasources available, or illegal option passed in via URL the plugin crashes

How can one reproduce the bug?

What is the expected behavior?

Screenshot 2024-04-19 at 11 16 01 AM

What is your host/environment?

Do you have any screenshots? If applicable, add screenshots to help explain your problem.

Do you have any additional context? Add any other context about the problem.

scrawfor99 commented 2 months ago

[Triage] Hi @derek-ho thanks for filing this issue. The follow-up design you provided seems like a good way to handle this scenario and looks like you have a good start on this. Going to mark triaged.

DarshitChanpura commented 2 months ago

A way to reproduce this issue:

  1. Log in as admin and create a user with security_rest_api_access role mapped to it (To be able to access the Security tab in left navigation pane)
  2. Create a dataSource connection to another cluster, say 9202.
  3. Now set 9202 as default dataSource.
  4. Log out as admin and login as the newly created user.
  5. Navigate to Security tab and you should see the following screen: Screenshot 2024-05-07 at 2 30 26 PM
DarshitChanpura commented 2 months ago

A BIG QUESTION here is if the user doesn't have access to default data-source then Switch to default data-source button is of no use since it will always bring you back to the same screen.

scrawfor99 commented 2 months ago

@DarshitChanpura @derek-ho do we have the ability to fetch a list of accessible datasources based on permissions? For instance, can we know that User A definitely has access to Datasource 1?

If so, we may be able to redirect to default if is accessible by the user and otherwise the last accessed datasource they have permission for?

If not, I suggest we enforce access for a disconnected landing page all users can hit. Similar to the login screen where they are not yet auth'd we can kick them back to a landing page regardless of their permissions and then have deterministic behavior in the case where the datasource is not permitted.

DarshitChanpura commented 1 month ago

do we have the ability to fetch a list of accessible datasources based on permissions? For instance, can we know that User A definitely has access to Datasource 1?

No we do not. DataSources information is stored as saved object inside the kibana and tenant index. When aggregation view is enabled, the user will require read permissions to the tenant which contains that particular datasource.

If not, I suggest we enforce access for a disconnected landing page all users can hit. Similar to the login screen where they are not yet auth'd we can kick them back to a landing page regardless of their permissions and then have deterministic behavior in the case where the datasource is not permitted.

There is no way to enforce that right now, so instead we bring them to a page which allows them to switch to local cluster. This scenario will only be required when aggregation view is enabled. When it is disabled, the page auto-reloads with default datasource.

DarshitChanpura commented 3 weeks ago

Corresponding PR closed. No plan to fix.