<?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: When posting setup.xml data to a custom endpoint, is it possible to make EAI calls that are properly authenticated and namespaced? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75438#M181366</link>
    <description>&lt;P&gt;well nothing is passed in as arguments (just what you'd expect like ["&lt;SPLUNK_HOME&gt;\bin\runScript.py", "execute"]), and there's nothing useful in os.environ either.   I forgot to mention that there &lt;EM&gt;is&lt;/EM&gt; a promising looking constant "splunk.admin.CONTEXT_APP_AND_USER" that you can pass into splunk.admin.init(), but it seems to have no effect.&lt;/SPLUNK_HOME&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 09:19:43 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2020-09-28T09:19:43Z</dc:date>
    <item>
      <title>When posting setup.xml data to a custom endpoint, is it possible to make EAI calls that are properly authenticated and namespaced?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75436#M181364</link>
      <description>&lt;P&gt;My problem seems very similar to 
&lt;A href="http://answers.splunk.com/questions/4175/redirects-before-and-after-our-apps-setup-xml-with-a-custom-eai-endpoint-is-sh" rel="nofollow"&gt;http://answers.splunk.com/questions/4175/redirects-before-and-after-our-apps-setup-xml-with-a-custom-eai-endpoint-is-sh&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;but either its not the same thing or that thing wasnt fixed in 4.1.5 (because im using 4.1.5)&lt;/P&gt;

&lt;P&gt;I have my setup.xml posting to my custom endpoint, and all is well. &lt;/P&gt;

&lt;P&gt;But from that endpoint I dont have any user context.  Specifically when I call &lt;CODE&gt;splunk.auth.getCurrentUser()&lt;/CODE&gt;,   i get back a placeholder user whose name is 'UNDEFINED_USER',  whereas I'd expect to get back the user currently logged into SplunkWeb. &lt;/P&gt;

&lt;P&gt;And obviously if i make namespaced EAI calls with that null user I cant do much with them cause he doesnt exist. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;and for troubleshooting purposes,  if i throw the following line in there, &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;hackSessionKey = splunk.auth.getSessionKey("admin", "changeme")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;then I do indeed get admin's user context and everything works fine, but of course that is not a solution.&lt;/P&gt;

&lt;P&gt;So can anyone tell me how to get the proper user context from here?  Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2010 07:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75436#M181364</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-10-22T07:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: When posting setup.xml data to a custom endpoint, is it possible to make EAI calls that are properly authenticated and namespaced?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75437#M181365</link>
      <description>&lt;P&gt;AFAIK, fixing the app context in the other issue linked above was easy because app context can be deduced from the URL. This makes the solution easy-- just make sure all app setups are sent (or redirected) to a URL for that app. &lt;/P&gt;

&lt;P&gt;The user, however, is stored in a cherrypy session variable instead of the URL, so you're dependent on having it passed from Splunkweb down to splunkd and then passed again from splunkd to your EAI python handler. I assume that one of those handoffs is not happening, or isn't happening as you'd expect. &lt;/P&gt;

&lt;P&gt;If I were trying to debug this, I'd suggest setting a breakpoint inside admin.init (the first method run in your EAI handler) and looking at all the info that splunkd is passing in as arguments and/or environment variables. &lt;/P&gt;

&lt;P&gt;If the username is in there, then figure out a way to suck it out. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;If the username isn't there, then I'd consider filing a support request on this since it sounds like something we may not currently support.  &lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2010 02:05:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75437#M181365</guid>
      <dc:creator>Justin_Grant</dc:creator>
      <dc:date>2010-10-23T02:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: When posting setup.xml data to a custom endpoint, is it possible to make EAI calls that are properly authenticated and namespaced?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75438#M181366</link>
      <description>&lt;P&gt;well nothing is passed in as arguments (just what you'd expect like ["&lt;SPLUNK_HOME&gt;\bin\runScript.py", "execute"]), and there's nothing useful in os.environ either.   I forgot to mention that there &lt;EM&gt;is&lt;/EM&gt; a promising looking constant "splunk.admin.CONTEXT_APP_AND_USER" that you can pass into splunk.admin.init(), but it seems to have no effect.&lt;/SPLUNK_HOME&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 09:19:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75438#M181366</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2020-09-28T09:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: When posting setup.xml data to a custom endpoint, is it possible to make EAI calls that are properly authenticated and namespaced?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75439#M181367</link>
      <description>&lt;P&gt;The solution was actually a headslapper.   Custom rest endpoints extend MConfigHandler, and in that file there is a method &lt;CODE&gt;getSessionKey()&lt;/CODE&gt;.  I think the setup endpoints I had been studying did filesystem operations only so they had never called it. &lt;/P&gt;

&lt;P&gt;Anyway, one might make the assumption that the python would inherit the authenticated  session automatically but you have to actually call &lt;CODE&gt;getSessionKey()&lt;/CODE&gt; or everything else will be dead in the water. &lt;/P&gt;

&lt;P&gt;I had tried &lt;CODE&gt;splunk.getDefault("sessionKey")&lt;/CODE&gt;,  and I had read all through the other EAI python and through the API docs, but the answer was right there in MConfigHandler.  Get a session key explicitly and suddenly ye shall be authenticated, and can make authenticated and properly-namespaced calls,  and you can call &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;splunk.auth.getCurrentUser()&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;and all manner of sensible things. &lt;/P&gt;

&lt;P&gt;This is the answer because without that all you can really do is simplistic writeConf calls:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;self.writeConf(confFileName, stanzaName, keyDictionary)&lt;/CODE&gt;   &lt;/P&gt;

&lt;P&gt;But with a sessionKey you get a user context and you can can then use any endpoint in the EAI system, for example: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;en.getEntities('data/inputs/monitor/_reload', sessionKey = self.getSessionKey())&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;which is very nice. &lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2010 01:58:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/When-posting-setup-xml-data-to-a-custom-endpoint-is-it-possible/m-p/75439#M181367</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2010-10-26T01:58:04Z</dc:date>
    </item>
  </channel>
</rss>

