<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to configure a Splunk app setup screen with user credentials? in Security</title>
    <link>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259037#M7107</link>
    <description>&lt;P&gt;I got it working - but only after reading the respective chapter in the "Splunk Developer's Guide";&lt;/P&gt;

&lt;P&gt;Here's how it goes:&lt;BR /&gt;
Suppose we have an app &lt;STRONG&gt;app&lt;/STRONG&gt;, with the need to configure 2 args: &lt;STRONG&gt;ip&lt;/STRONG&gt;, and &lt;STRONG&gt;token&lt;/STRONG&gt;&lt;BR /&gt;
A.&lt;BR /&gt;
The first thing we need to do is to define an &lt;EM&gt;endpoint&lt;/EM&gt; and its &lt;EM&gt;member&lt;/EM&gt; (&lt;STRONG&gt;appep&lt;/STRONG&gt;, &lt;STRONG&gt;conf&lt;/STRONG&gt;). &lt;BR /&gt;
This is done in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/default/restmap.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[admin:app]
  match=/appep
  members=conf

[admin_external:conf]
  handlertype = python
  handlerfile = app_handler.py
  handleractions = list, edit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(&lt;BR /&gt;
if it got unclear with the code highlighting:&lt;BR /&gt;
[admin:app]&lt;BR /&gt;
    match=/appep&lt;BR /&gt;
    members=conf&lt;/P&gt;

&lt;P&gt;[admin_external:conf]&lt;BR /&gt;
   handlertype = python&lt;BR /&gt;
   handlerfile = app_handler.py&lt;BR /&gt;
   handleractions = list, edit&lt;BR /&gt;
)&lt;/P&gt;

&lt;P&gt;B.&lt;BR /&gt;
Next, we need to create a conf file, &lt;STRONG&gt;appsetup.conf&lt;/STRONG&gt;, listing our arguments, in their own stanza, named after our &lt;STRONG&gt;entity&lt;/STRONG&gt;. &lt;BR /&gt;
This is done in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/default/&lt;STRONG&gt;appsetup.conf:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[app_config]
ip =
token =
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;C.&lt;BR /&gt;
Now we need to build a setup.xml file, basically describing the dialog. &lt;BR /&gt;
This is done in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/default/setup.xml:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;setup&amp;gt;
        &amp;lt;block title="Your configuration screen title goes here" endpoint="appep/conf" entity="app_config"&amp;gt;
                &amp;lt;input field="ip"&amp;gt;
                        &amp;lt;label&amp;gt;Valid prompt for ip&amp;lt;/label&amp;gt;
                        &amp;lt;type&amp;gt;text&amp;lt;/type&amp;gt;
                &amp;lt;/input&amp;gt;
                &amp;lt;input field="token"&amp;gt;
                        &amp;lt;label&amp;gt;Valid prompt for token&amp;lt;/label&amp;gt;
                        &amp;lt;type&amp;gt;text&amp;lt;/type&amp;gt;
                &amp;lt;/input&amp;gt;
        &amp;lt;/block&amp;gt;
&amp;lt;/setup&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;D.&lt;BR /&gt;
Last but not least - we need the &lt;STRONG&gt;app_handler.py&lt;/STRONG&gt; python script mentioned in the restmap.conf. &lt;BR /&gt;
It is there to make the configuration persist, basically. In other words, perhaps, the code behind the "save" button. It goes to $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/bin/&lt;STRONG&gt;app_handler.py&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunk.admin as admin
import splunk.entity as en

class ConfigApp(admin.MConfigHandler):
  def setup(self):
    if self.requestedAction == admin.ACTION_EDIT:
      for myarg in ['ip', 'token']:
        self.supportedArgs.addOptArg(myarg)

  def handleList(self, confInfo):
    confDict = self.readConf("appsetup")
    if None != confDict:
      for stanza, settings in confDict.items():
        for key, val in settings.items():
          if key in ['ip', 'token'] and val in [None, '']:
            val = ''
          confInfo[stanza].append(key, val)

  def handleEdit(self, confInfo):
    name = self.callerArgs.id
    args = self.callerArgs
    self.writeConf('appsetup', 'app_config', self.callerArgs.data)

admin.init(ConfigApp, admin.CONTEXT_NONE)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;E.&lt;BR /&gt;
Finally, restart splunk.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;When you start the app first, you'll be prompted to go to the configuration screen.&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Everything you    save will be kept in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/local/appsetup&lt;/LI&gt;
&lt;LI&gt;To troubleshoot Python syntax errors, you best look at splunkd.log in  $SPLUNK_HOME/var/log&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Tue, 29 Sep 2020 08:42:25 GMT</pubDate>
    <dc:creator>ramabu</dc:creator>
    <dc:date>2020-09-29T08:42:25Z</dc:date>
    <item>
      <title>How to configure a Splunk app setup screen with user credentials?</title>
      <link>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259036#M7106</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I apologize if the following is a stupid question.&lt;/P&gt;

&lt;P&gt;I have not been able to take the sample_app configuration example listed in &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.2/AdvancedDev/SetupExampleCredentials"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.2/AdvancedDev/SetupExampleCredentials&lt;/A&gt; &lt;BR /&gt;
and apply it to my use case.&lt;/P&gt;

&lt;P&gt;I can see that there has to be a setup.xml&lt;BR /&gt;
I can see that it refers to endpoints and entities.&lt;BR /&gt;
I can see the need for corresponding conf files.&lt;BR /&gt;
I also see a correspondence to restmap.conf entries, and in turn to some python configurator script (not in that doc, though).&lt;/P&gt;

&lt;P&gt;I fail to see the model behind this. &lt;/P&gt;

&lt;P&gt;If I want an app with a couple of text fields (neither are user-name/password):&lt;BR /&gt;
what endpoint/entities should I use? It is probably my call; say, &lt;EM&gt;endpoint="admin/myconf" entity="mysettings"&lt;/EM&gt;. &lt;BR /&gt;
but then, where else should I define "myconf"? "mysettings"? which if at all should be in inputs.conf? &lt;BR /&gt;
When is a .py script required? &lt;/P&gt;

&lt;P&gt;Is there a "for dummies" writeup for this that I can refer to?&lt;/P&gt;

&lt;P&gt;Thanks for reading so far!&lt;BR /&gt;
rama&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jan 2016 10:29:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259036#M7106</guid>
      <dc:creator>ramabu</dc:creator>
      <dc:date>2016-01-31T10:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure a Splunk app setup screen with user credentials?</title>
      <link>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259037#M7107</link>
      <description>&lt;P&gt;I got it working - but only after reading the respective chapter in the "Splunk Developer's Guide";&lt;/P&gt;

&lt;P&gt;Here's how it goes:&lt;BR /&gt;
Suppose we have an app &lt;STRONG&gt;app&lt;/STRONG&gt;, with the need to configure 2 args: &lt;STRONG&gt;ip&lt;/STRONG&gt;, and &lt;STRONG&gt;token&lt;/STRONG&gt;&lt;BR /&gt;
A.&lt;BR /&gt;
The first thing we need to do is to define an &lt;EM&gt;endpoint&lt;/EM&gt; and its &lt;EM&gt;member&lt;/EM&gt; (&lt;STRONG&gt;appep&lt;/STRONG&gt;, &lt;STRONG&gt;conf&lt;/STRONG&gt;). &lt;BR /&gt;
This is done in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/default/restmap.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[admin:app]
  match=/appep
  members=conf

[admin_external:conf]
  handlertype = python
  handlerfile = app_handler.py
  handleractions = list, edit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(&lt;BR /&gt;
if it got unclear with the code highlighting:&lt;BR /&gt;
[admin:app]&lt;BR /&gt;
    match=/appep&lt;BR /&gt;
    members=conf&lt;/P&gt;

&lt;P&gt;[admin_external:conf]&lt;BR /&gt;
   handlertype = python&lt;BR /&gt;
   handlerfile = app_handler.py&lt;BR /&gt;
   handleractions = list, edit&lt;BR /&gt;
)&lt;/P&gt;

&lt;P&gt;B.&lt;BR /&gt;
Next, we need to create a conf file, &lt;STRONG&gt;appsetup.conf&lt;/STRONG&gt;, listing our arguments, in their own stanza, named after our &lt;STRONG&gt;entity&lt;/STRONG&gt;. &lt;BR /&gt;
This is done in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/default/&lt;STRONG&gt;appsetup.conf:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[app_config]
ip =
token =
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;C.&lt;BR /&gt;
Now we need to build a setup.xml file, basically describing the dialog. &lt;BR /&gt;
This is done in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/default/setup.xml:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;setup&amp;gt;
        &amp;lt;block title="Your configuration screen title goes here" endpoint="appep/conf" entity="app_config"&amp;gt;
                &amp;lt;input field="ip"&amp;gt;
                        &amp;lt;label&amp;gt;Valid prompt for ip&amp;lt;/label&amp;gt;
                        &amp;lt;type&amp;gt;text&amp;lt;/type&amp;gt;
                &amp;lt;/input&amp;gt;
                &amp;lt;input field="token"&amp;gt;
                        &amp;lt;label&amp;gt;Valid prompt for token&amp;lt;/label&amp;gt;
                        &amp;lt;type&amp;gt;text&amp;lt;/type&amp;gt;
                &amp;lt;/input&amp;gt;
        &amp;lt;/block&amp;gt;
&amp;lt;/setup&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;D.&lt;BR /&gt;
Last but not least - we need the &lt;STRONG&gt;app_handler.py&lt;/STRONG&gt; python script mentioned in the restmap.conf. &lt;BR /&gt;
It is there to make the configuration persist, basically. In other words, perhaps, the code behind the "save" button. It goes to $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/bin/&lt;STRONG&gt;app_handler.py&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunk.admin as admin
import splunk.entity as en

class ConfigApp(admin.MConfigHandler):
  def setup(self):
    if self.requestedAction == admin.ACTION_EDIT:
      for myarg in ['ip', 'token']:
        self.supportedArgs.addOptArg(myarg)

  def handleList(self, confInfo):
    confDict = self.readConf("appsetup")
    if None != confDict:
      for stanza, settings in confDict.items():
        for key, val in settings.items():
          if key in ['ip', 'token'] and val in [None, '']:
            val = ''
          confInfo[stanza].append(key, val)

  def handleEdit(self, confInfo):
    name = self.callerArgs.id
    args = self.callerArgs
    self.writeConf('appsetup', 'app_config', self.callerArgs.data)

admin.init(ConfigApp, admin.CONTEXT_NONE)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;E.&lt;BR /&gt;
Finally, restart splunk.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;When you start the app first, you'll be prompted to go to the configuration screen.&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Everything you    save will be kept in $SPLUNK_HOME/etc/apps/&lt;STRONG&gt;app&lt;/STRONG&gt;/local/appsetup&lt;/LI&gt;
&lt;LI&gt;To troubleshoot Python syntax errors, you best look at splunkd.log in  $SPLUNK_HOME/var/log&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:42:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259037#M7107</guid>
      <dc:creator>ramabu</dc:creator>
      <dc:date>2020-09-29T08:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure a Splunk app setup screen with user credentials?</title>
      <link>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259038#M7108</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
 Above example was much more clear for understanding. I just tried your setting and configuration as u mentioned above. But, When I launch app setup.xml is not prompted.&lt;BR /&gt;
Do u know anything went wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 11:01:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259038#M7108</guid>
      <dc:creator>sumangala</dc:creator>
      <dc:date>2017-05-09T11:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure a Splunk app setup screen with user credentials?</title>
      <link>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259039#M7109</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Thanks for spending time posting the answer. It really helped. Really concise and clear. Easy and understandable. Been stuck at it for days. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
Hriday.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2017 10:18:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259039#M7109</guid>
      <dc:creator>hridayns</dc:creator>
      <dc:date>2017-06-13T10:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to configure a Splunk app setup screen with user credentials?</title>
      <link>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259040#M7110</link>
      <description>&lt;P&gt;Very nicely written. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 07:04:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/How-to-configure-a-Splunk-app-setup-screen-with-user-credentials/m-p/259040#M7110</guid>
      <dc:creator>meenal901</dc:creator>
      <dc:date>2017-08-25T07:04:01Z</dc:date>
    </item>
  </channel>
</rss>

