All Apps and Add-ons

How to get encrypted password fields during modular input parameters validation?

umairahmad3985
Path Finder

Hi all,

I am stuck in a very unfortunate condition. I am developing a modular input (using Splunk Add-on builder) that takes two input parameters, a Base URL and an API key. I am interested in validating both in my validate_input by sending a request to our server and if the response is good, then let the user save the input parameters. The problem is that my API key input parameter is of type password and in my validate_input method, I am only able to get its encrypted value in the form of ***********. How can I get its plain value so that I can use it to send request to the server? Here's my sample code for the validate_input method.

def validate_input(helper, definition):
    """Implement your own validation logic to validate the input stanza configurations"""
    # This example accesses the modular input variable
    snx_base_url = definition.parameters.get('snx_base_url', None)
    snx_api_key = definition.parameters.get('snx_api_key', None)

Please point me in a direction that can help me achieve the above. I shall be highly thankful to you!

Regards,
Umair

0 Karma

pmeyerson
Path Finder

From what I understand, if you just mark it as a password type input, it does not actually store the input encrypted in passwords.conf, just masks it on the screen.

What worked for me is setting up a global account (checkbox in add-on builder), this gives us a way to enter a username and password, which are then encrypted in passwords.conf.  To retreive, use helper.get_arg("credential_name"), where credential_name is what you call the input where the user selects which credential to use.  HTH

0 Karma

tomapatan
Communicator

Apologies, but would really appreciate a more detailed set of instructions - can`t get my head round how adding a checkbox helps with the encryption and how to actually achieve this ?

Many thanks!

0 Karma

codebuilder
Influencer

I do not have experience doing this programmatically, but the command below is the CLI version of what you're looking for. It may help (be sure to enclose the value in tick marks as in the example)...

/opt/splunk/bin/splunk show-decrypted --value 'pass4Symmkey_value_here'
----
An upvote would be appreciated and Accept Solution if it helps!
0 Karma

umairahmad3985
Path Finder

No use doing it by CLI. Need to do this in my modular input script. Thanks though!

0 Karma
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...