Getting Data In

negotiate authentication in custom python search commands

cphair
Builder

Hello,

I'd like to use a custom search command that makes a live REST query to another system with a special account and returns the results to Splunk. Unfortunately, the other system uses Windows client credentials (my script is running on a Windows search head) and doesn't like basic authentication--the script errors out with a 401 when it tries to open the URL. With the modules provided in Splunk 4.3.4's Python (Python 2.7.2, I guess), is it possible to make the REST call with another account's credentials without using basic auth? I've looked for non-Splunk Python code examples, and they either use basic auth or they use the ntlm module, which doesn't appear to be included in Splunk Python by default.

0 Karma

dart
Splunk Employee
Splunk Employee

I'd suggest using this technique to include another python library, such as requests.

I've also used an alternate technique of shelling out to another script, in this case perl, but you could do so to use system python instead.

#! /usr/bin/env python
"""
    Python wrapper script for the perl script
"""
import os,sys

script = r'/path/to/my/script.pl'

os.execv(script, sys.argv[1])
0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...