<?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: Save more than one password using setup.xml OR &amp;quot;storage/passwords&amp;quot; in Security</title>
    <link>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338496#M13171</link>
    <description>&lt;P&gt;I would recommend using the Splunk add on builder. It provides UI etc for handling credentials and whatever inputs or alerts you are making. &lt;/P&gt;</description>
    <pubDate>Wed, 18 Apr 2018 02:51:07 GMT</pubDate>
    <dc:creator>starcher</dc:creator>
    <dc:date>2018-04-18T02:51:07Z</dc:date>
    <item>
      <title>Save more than one password using setup.xml OR "storage/passwords"</title>
      <link>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338495#M13170</link>
      <description>&lt;P&gt;I faced a challenge and tried many things to work around for saving 2 passwords in the password.conf at the same time using the setup.xml.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Is the Credential&lt;/LI&gt;
&lt;LI&gt;Is the Client Certificate Passphrase&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Setup.xml code:  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;setup&amp;gt;
        &amp;lt;block title="Credentials" endpoint="storage/passwords" entity="_new"&amp;gt;
            &amp;lt;text&amp;gt; Leave username/password blank, if you have already set it up.&amp;lt;/text&amp;gt;
            &amp;lt;input field="realm"&amp;gt; 
                &amp;lt;label&amp;gt;Role&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="name"&amp;gt;
                &amp;lt;label&amp;gt;Username&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="password"&amp;gt;
                &amp;lt;label&amp;gt;Password&amp;lt;/label&amp;gt;
                &amp;lt;type&amp;gt;password&amp;lt;/type&amp;gt;
            &amp;lt;/input&amp;gt;        
        &amp;lt;/block&amp;gt;

        &amp;lt;block title="Client Certificate" endpoint="myapp/myapp_configure" entity="setupentity"&amp;gt;
            &amp;lt;input field="use_ca"&amp;gt;
                &amp;lt;label&amp;gt;Use a Client certificate for authentication&amp;lt;/label&amp;gt;
                &amp;lt;type&amp;gt;bool&amp;lt;/type&amp;gt;
            &amp;lt;/input&amp;gt;

            &amp;lt;input field="ca_path"&amp;gt;
                &amp;lt;label&amp;gt;Path to client CA certificate &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="ca_key"&amp;gt;
                &amp;lt;label&amp;gt;Path to client CA certificate key &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;block title="Client Certificate Passphrase" endpoint="storage/passwords" entity="_new"&amp;gt;        
            &amp;lt;input field="ca_pass"&amp;gt;
                &amp;lt;label&amp;gt;Passphrase for client CA certificate&amp;lt;/label&amp;gt;
                &amp;lt;type&amp;gt;password&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;The Passphrase is not saved.&lt;BR /&gt;
P.S. I have created the python handler, default/myapp.conf with all the fields. The restmap.conf also has endpoint="myapp/myapp_configure". The Credentials are saved with Role/realm.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2018 04:11:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338495#M13170</guid>
      <dc:creator>pbankar</dc:creator>
      <dc:date>2018-04-17T04:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Save more than one password using setup.xml OR "storage/passwords"</title>
      <link>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338496#M13171</link>
      <description>&lt;P&gt;I would recommend using the Splunk add on builder. It provides UI etc for handling credentials and whatever inputs or alerts you are making. &lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 02:51:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338496#M13171</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2018-04-18T02:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Save more than one password using setup.xml OR "storage/passwords"</title>
      <link>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338497#M13172</link>
      <description>&lt;P&gt;Thanks, @starcher for your input. I'm looking for a code level solution.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 06:22:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338497#M13172</guid>
      <dc:creator>pbankar</dc:creator>
      <dc:date>2018-04-18T06:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: Save more than one password using setup.xml OR "storage/passwords"</title>
      <link>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338498#M13173</link>
      <description>&lt;P&gt;I got an answer for this problem using the &lt;CODE&gt;import splunklib.client as client&lt;/CODE&gt; in the &lt;CODE&gt;&amp;lt;app&amp;gt;_splunk_setup_handler.py&lt;/CODE&gt; script. &lt;BR /&gt;
I'm saving the password in my &lt;CODE&gt;app/local/password.conf&lt;/CODE&gt; and retrieving it using the splunk session and &lt;CODE&gt;service.storage_passwords&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Created these 2 type of methods:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;'''Get clear password'''
def get_password(session_key, username, realm):
    args = {'token': session_key, 'app': "my_app"}
    service = client.connect(**args)
    try:
        # Retrieve the password from the storage/passwords endpoint
        for storage_password in service.storage_passwords:
            if storage_password.username == username and storage_password.realm == realm:
                return storage_password.content.clear_password
    except Exception, e:
        raise Exception, "An error occurred while decrypting credentials. Details: %s" % str(e)

'''Encripting the password'''
def encrypt_password(service, ca_pass, username, realm):
    try:
        # If the credential already exists, delete it.
        for storage_password in service.storage_passwords:
            if storage_password.username == username and storage_password.realm == realm:
                service.storage_passwords.delete(username, realm)
        # Create the credential.
        password = service.storage_passwords.create(ca_pass, username, realm)
        return password.encrypted_password
    except Exception, e:
        raise Exception, "An error occurred while encrypting credentials. Details: %s" % str(e)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 May 2018 05:24:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/Save-more-than-one-password-using-setup-xml-OR-quot-storage/m-p/338498#M13173</guid>
      <dc:creator>pbankar</dc:creator>
      <dc:date>2018-05-14T05:24:30Z</dc:date>
    </item>
  </channel>
</rss>

