<?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: getting storage passwords using python sdk in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304681#M3942</link>
    <description>&lt;P&gt;Just to recap.&lt;/P&gt;

&lt;P&gt;Make sure you are getting the valid session key. Print it out. You could also test your code by substituting a connect by a static username/password combo temporarily &lt;/P&gt;

&lt;P&gt;You might try changing your sessions to the following. Since you are getting the storage password list, app is going to be irrelvant.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service = client.connect(token=session_key)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Confirm what user context the knowledge object is running under (input/alert etc), I suspect that nobody or your session key is causing you the issue.&lt;BR /&gt;
 &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#currentuser" target="_blank"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#currentuser&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Ensure that user has the list_storage_passwords capability.&lt;/P&gt;

&lt;P&gt;Use something like this to grab just the credential that matches the desired realm and username&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; retrievedCredential = [k for k in storage_passwords if k.content.get('realm')==realm and k.content.get('username')==username][0]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2020 12:52:30 GMT</pubDate>
    <dc:creator>starcher</dc:creator>
    <dc:date>2020-09-29T12:52:30Z</dc:date>
    <item>
      <title>getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304670#M3931</link>
      <description>&lt;P&gt;Hi There,&lt;/P&gt;

&lt;P&gt;We are getting reports that the Mimecast for Splunk app is failing to return our credentials from splunk secure storage using Splunk version 6.5.1. The app uses the Splunk Python SDK for this function.&lt;/P&gt;

&lt;P&gt;The exception that we are getting is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;class 'xml.etree.ElementTree.ParseError'&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is a sample of the code we use here:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    try:
        import splunklib.client as client

        service = client.connect(token=params["session_key"], app="mimecast_for_splunk", owner="nobody")
        storage_passwords = service.storage_passwords
        for storage_password in storage_passwords:
            if storage_password.realm == "mimecast_for_splunk":
                 -----truncated------
   except:
       # code to add the exception to a log file on disk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any help or guidance on this would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 13:40:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304670#M3931</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2017-02-15T13:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304671#M3932</link>
      <description>&lt;P&gt;Looks like some xml parsing issues... do you parse xml in the code?  Are there any other errors?  &lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 15:22:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304671#M3932</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-02-15T15:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304672#M3933</link>
      <description>&lt;P&gt;Thank you for your reply. I don;t do any parsing myself, I leave that to SDK. I'm expecting an array back from:&lt;/P&gt;

&lt;P&gt;storage_passwords = service.storage_passwords&lt;/P&gt;

&lt;P&gt;What do you think?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:53:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304672#M3933</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2020-09-29T12:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304673#M3934</link>
      <description>&lt;P&gt;does service even work?&lt;/P&gt;

&lt;P&gt;curious how you're getting the session key, if youre passing auth in commands.conf or not.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 15:29:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304673#M3934</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2017-02-15T15:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304674#M3935</link>
      <description>&lt;P&gt;It does, we are only seeing this with 1 or 2 customers. &lt;/P&gt;

&lt;P&gt;The script runs as a modular input so I get the session key from std in on script startup.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 15:31:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304674#M3935</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2017-02-15T15:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304675#M3936</link>
      <description>&lt;P&gt;Does the user firing the alert have the capability: list_storage_passwords ?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:52:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304675#M3936</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2020-09-29T12:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304676#M3937</link>
      <description>&lt;P&gt;You might also want to do something more like the following to get a specific credential matching the desired realm and username. just a little more compact that the typical for loop structure.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;retrievedCredential = [k for k in storage_passwords if k.content.get('realm')==realm and k.content.get('username')==username][0]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Feb 2017 16:15:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304676#M3937</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2017-02-15T16:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304677#M3938</link>
      <description>&lt;P&gt;Thanks for that, wouldn't Modular Inputs run as the user running the splunk service?&lt;/P&gt;

&lt;P&gt;How would we check what user context this is being run under and if they have that permission?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 18:29:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304677#M3938</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2017-02-15T18:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304678#M3939</link>
      <description>&lt;P&gt;It runs as whomever (splunk user) owns the search that fired. That is not the same thing as what splunkd runs as. You are confusing OS vs Application users.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 18:32:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304678#M3939</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2017-02-15T18:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304679#M3940</link>
      <description>&lt;P&gt;OK, I would understand that if this was triggered by a search but this is triggered as a Data Input.&lt;/P&gt;

&lt;P&gt;Apologies if I am misunderstanding.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 18:43:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304679#M3940</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2017-02-15T18:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304680#M3941</link>
      <description>&lt;P&gt;All knowledge objects still have owners. The session key is going to auth as whomever that is. That will determine the permissions/capability by role.&lt;/P&gt;

&lt;P&gt;This shows you how in your code to tell which user you are.&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#currentuser"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#currentuser&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 18:48:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304680#M3941</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2017-02-15T18:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: getting storage passwords using python sdk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304681#M3942</link>
      <description>&lt;P&gt;Just to recap.&lt;/P&gt;

&lt;P&gt;Make sure you are getting the valid session key. Print it out. You could also test your code by substituting a connect by a static username/password combo temporarily &lt;/P&gt;

&lt;P&gt;You might try changing your sessions to the following. Since you are getting the storage password list, app is going to be irrelvant.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service = client.connect(token=session_key)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Confirm what user context the knowledge object is running under (input/alert etc), I suspect that nobody or your session key is causing you the issue.&lt;BR /&gt;
 &lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#currentuser" target="_blank"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAEJ6#currentuser&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Ensure that user has the list_storage_passwords capability.&lt;/P&gt;

&lt;P&gt;Use something like this to grab just the credential that matches the desired realm and username&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; retrievedCredential = [k for k in storage_passwords if k.content.get('realm')==realm and k.content.get('username')==username][0]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:52:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/getting-storage-passwords-using-python-sdk/m-p/304681#M3942</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2020-09-29T12:52:30Z</dc:date>
    </item>
  </channel>
</rss>

