|
My problem seems very similar to http://answers.splunk.com/questions/4175/redirects-before-and-after-our-apps-setup-xml-with-a-custom-eai-endpoint-is-sh but either its not the same thing or that thing wasnt fixed in 4.1.5 (because im using 4.1.5) I have my setup.xml posting to my custom endpoint, and all is well. But from that endpoint I dont have any user context. Specifically when I call And obviously if i make namespaced EAI calls with that null user I cant do much with them cause he doesnt exist. =) and for troubleshooting purposes, if i throw the following line in there,
then I do indeed get admin's user context and everything works fine, but of course that is not a solution. So can anyone tell me how to get the proper user context from here? Thanks in advance. |
|
The solution was actually a headslapper. Custom rest endpoints extend MConfigHandler, and in that file there is a method Anyway, one might make the assumption that the python would inherit the authenticated session automatically but you have to actually call I had tried
and all manner of sensible things. This is the answer because without that all you can really do is simplistic writeConf calls:
But with a sessionKey you get a user context and you can can then use any endpoint in the EAI system, for example:
which is very nice. |
|
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. 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. 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. If the username is in there, then figure out a way to suck it out. :-) 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. well nothing is passed in as arguments (just what you'd expect like ["<splunk_home>binrunScript.py", "execute"]), and there's nothing useful in os.environ either. I forgot to mention that there is 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.
(23 Oct '10, 00:26)
nick ♦
|
