All Apps and Add-ons

Custom Authentication Handler for session id

mdorobek
Path Finder

Hello there,

I try to use a custom authentication handler to set a header with a session-ID I get from another REST request.
Heres my class in the authhandlers.py

class AuthHeader(AuthBase):

    def __init__(self,**args):
        self.username = args['username']
        self.password = args['password']
        self.ip = args['ip']

    def __call__(self, r):

        url = "https://" + self.ip + "/api/endeavour/session"
        session_json = requests.post(url, verify=False, auth=HTTPBasicAuth(self.username, self.password))
        session_json.json()['sessionid']
        headers = {'content-type':application/json, 'accept':application/json, 'x-endeavour-sessionid':session_json.json()['sessionid']}
        r.headers = headers
        return r

And heres my config in the GUI:
alt text

Somehow this doesnt work and I dont get any events. Can somone help me and find the mistake?

Kind regards,
mdorobek

0 Karma
1 Solution

mdorobek
Path Finder

Turns out it was a missing import. I had to import requests.

View solution in original post

0 Karma

mdorobek
Path Finder

Turns out it was a missing import. I had to import requests.

0 Karma

Damien_Dallimor
Ultra Champion

You'll have better luck in the BaboonBones Community Slack (you would have received a complimentary invite with your key), or you can get free access at http://www.baboonbones.com/#support

0 Karma

mdorobek
Path Finder

I just found a solution.

Nevertheless thank you, I received the key by a colleague and didn't know there is a community. I will try it in future if I have another question.

0 Karma
Get Updates on the Splunk Community!

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...