Security

How to add a custom navigation item (Logout option) to the Splunkbar User Menu?

J8K3
Engager

I would like to add a custom logout link to the Splunkbar User Menu (see image). I am using SSO which causes the default "Logout" option to be hidden. I would like to add a custom "Logout" option pointing to my SSO provider logout page. I have tried to modify the file below, however, my modifications do not seem to take effect, even after restarting Splunk.

<drive>:\Program Files\Splunk\share\splunk\search_mrsparkle\exposed\js\views\shared\splunkbar\UserMenu.html

I have modified the file to look like this:

<a href="#" class="dropdown-toggle"><span class="realname"><%-realName%></span><b class="caret"></b></a>
<div class="dropdown-menu dropdown-menu-narrow global-user-menu">
    <div class="arrow"></div>
    <ul>
        <li><a href="<%-accountLink%>" class="edit"><%- _("Edit Account").t() %></a></li>
    <li><a class="logout" href="/vdesk/hangup.php3">Logout</a></li>
    </ul>
</div>

alt text

0 Karma

LukeMurphey
Champion

You can do this with some custom Javascript. Just add the following to your dashboard.js file in the app ($SPLUNK_HOME/etc/apps//appserver/static/dashboard.js):

require([
         "jquery",
         "splunkjs/mvc/simplexml/ready!"
     ], function($)
     {
        function modifyMenu(){
            if( $('.global-user-menu').length > 0 ){
                $('.global-user-menu').append('<li><a href="http://google.com">Go to Google.com</a></li>');
            }
            else{
                setTimeout(modifyMenu, 300);
            }
        }

        modifyMenu();
     }
);

The benefit of using dashboard.js is that it survive Splunk upgrades.

Caveats
This will work for all dashboards since they load dashboard.js. This will not work for some pages such as the search view since this does not load dashboard.js.

J8K3
Engager

Can anyone explain why my original approach of modifying :\Program Files\Splunk\share\splunk\search_mrsparkle\exposed\js\views\shared\splunkbar\UserMenu.html didn't work?

GregZillgitt
Path Finder

I'm curious also. I tried fiddling with splunkbar/Master.html but my changes had no effect.

0 Karma

prathikpisplunk
Explorer

Anybody found answer for this ? Please respond

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...