how to add new menu items for searchguard_readonly_mode

  • Search Guard and Elasticsearch version

→ 6.5.4

  • Installed and used enterprise modules, if any

→ Using community edition searchguard

  • JVM version and operating system version

JVM - Java 1.8.0

OS - Windows 7

  • Search Guard configuration files

  • Elasticsearch log messages on debug level

  • Other installed Elasticsearch or Kibana plugins, if any

– No other plugins

I have added more menu items (dashboard menus) in the left pane of kibana.

I want to add these menus for searchguard.readonly_mode.roles

How to do it…

Hi there,

This will be a lot easier in an upcoming (soon) release with improved access control.
For now, if you have the possibility to change the code, I think the best way to show more menu items for those users would be to add the items here:

https://github.com/floragunncom/search-guard-kibana-plugin/blob/6.x/public/chrome/readonly/enable_readonly.js#L115

If you know the id of those items, you should be able to add them to that list, like this
let visibleNavLinkIds = [
‘kibana:dashboard’,
‘yourMenuItem’,
‘yourSecondMenuItem’
];

Hope this helps for now!

Best Regards
Mike

Thank you for help. I’ll try it and let you know if it works.

Its not working .
I have added
like

enable_readonly.js
/**

  • Hide navigation links that aren’t needed in the dashboard only mode.

  • @param {Boolean} multitenancyVisible - If true, we won’t hide the
    */
    function hideNavItemsForDashboardOnly(multitenancyVisible) {
    let visibleNavLinkIds = [
    ‘kibana:dashboard’,‘kibana:school’
    ];

    if (multitenancyVisible) {
    visibleNavLinkIds.push(‘searchguard-multitenancy’);
    }

    chrome.getNavLinks().forEach((navLink) => {
    if (visibleNavLinkIds.indexOf(navLink.id) === -1) {
    // A bit redundant if all items are hidden from the start
    navLink.hidden = true;
    } else if (originalNavItemsVisibility !== null) {
    navLink.hidden = originalNavItemsVisibility[navLink.id];
    }
    });
    }

and in index.js
, {
id: ‘kibana:school’,
title: ‘School Report’,
order: -1004,
url: ${kbnBaseUrl}#/dashboard/169346d0-14a9-11e9-a4bc-a7d61b69fdb6?_g=(),
// The subUrlBase is the common substring of all urls for this app. If not given, it defaults to the url
// above. This app has to use a different subUrlBase, in addition to the url above, because “#/dashboard”
// routes to a page that creates a new dashboard. When we introduced a landing page, we needed to change
// the url above in order to preserve the original url for BWC. The subUrlBase helps the Chrome api nav
// to determine what url to use for the app link.
subUrlBase: ${kbnBaseUrl}#/dashboard,
description: ‘compose visualizations for much win’,
icon: ‘plugins/kibana/assets/dashboard.svg’,
euiIconType: ‘dashboardApp’
}

Hmm I just tested this, and it seems wo work. My guess would be, that you should write school instead of kibana:school.

To find the id of the apps, you cann add this line to output all the apps/navLinks - the id property for your app is the one you should use.
console.log(chrome.getNavLinks());

Hope this helps!