wazuh / wazuh-dashboard-plugins

Plugins for Wazuh Dashboard
https://wazuh.com/
GNU General Public License v2.0
434 stars 181 forks source link

ODFE 1.13.0 Select your tenant message popping up every time we log in #3496

Open MiguelCasaresRobles opened 3 years ago

MiguelCasaresRobles commented 3 years ago
Wazuh Elastic Rev
4.1.5 7.10.12/1.13.2 444

Description ODFE 1.13.0 Select your tenant message popping up every time we log in, even with the following configuration:

server.defaultRoute: /app/wazuh?security_tenant=global
opendistro_security.multitenancy.enabled: true
opendistro_security.multitenancy.enable_filter: true
opendistro_security.multitenancy.tenants.preferred: ["Global"]
opendistro_security.multitenancy.tenants.enable_private: false

If we check the remember my option it will appear too so none of the solutions aforementioned are working.

image

We should do something to get rid of this message.

frankeros commented 2 years ago

I have been working to find a solution to this. The only way I found to solve was changing the source code of the plugin https://github.com/opendistro-for-elasticsearch/security-kibana-plugin

I try to solve two bugs about the multitenancy modal:

See the changes:

## Diff with the last tag v1.13.0.1 ```js diff --git a/public/apps/account/account-app.tsx b/public/apps/account/account-app.tsx index e07f8daf..f62907fa 100644 --- a/public/apps/account/account-app.tsx +++ b/public/apps/account/account-app.tsx @@ -47,7 +47,7 @@ export async function setupTopNavButton(coreStart: CoreStart, config: ClientConf let tenant = accountInfo.user_requested_tenant; let shouldShowTenantPopup = true; - if (tenantSpecifiedInUrl() || getShouldShowTenantPopup() === false) { + if (tenantSpecifiedInUrl() || getShouldShowTenantPopup() === false || config.multitenancy.enabled === false) { shouldShowTenantPopup = false; } else { // Switch to previous tenant based on localStorage, it may fail due to diff --git a/public/apps/account/account-nav-button.tsx b/public/apps/account/account-nav-button.tsx index 23b2d772..06d407c4 100644 --- a/public/apps/account/account-nav-button.tsx +++ b/public/apps/account/account-nav-button.tsx @@ -105,10 +105,14 @@ export function AccountNavButton(props: { > View roles and identities - {horizontalRule} - - Switch tenants - + {props.config.multitenancy.enabled && ( + <> + {horizontalRule} + + Switch tenants + + + )} {props.isInternalUser && ( <> {horizontalRule} diff --git a/public/utils/storage-utils.tsx b/public/utils/storage-utils.tsx index 0bee9a2b..695d9a0c 100644 --- a/public/utils/storage-utils.tsx +++ b/public/utils/storage-utils.tsx @@ -60,11 +60,11 @@ const TENANT_SHOW_POPUP_KEY = 'show_popup'; const TENANT_SAVED_KEY = 'saved'; export function getShouldShowTenantPopup(): boolean | null { - return getValue(sessionStorage, TENANT_CATEGORY, TENANT_SHOW_POPUP_KEY); + return getValue(localStorage, TENANT_CATEGORY, TENANT_SHOW_POPUP_KEY); } export function setShouldShowTenantPopup(value: boolean | null): void { - setValue(sessionStorage, TENANT_CATEGORY, TENANT_SHOW_POPUP_KEY, value); + setValue(localStorage, TENANT_CATEGORY, TENANT_SHOW_POPUP_KEY, value); } export function getSavedTenant(): string | null { ```

Multitenancy was enabled by default in our installations because of a previous bug downloading reports with multitenancy disabled. It was described here. With this change, I could download reports without problems.

image image

The customer package

opendistroSecurityKibana-7.10.2.zip