Security

Delete or change generated "Confirm Password" field in setup.xml

msivill_splunk
Splunk Employee
Splunk Employee

I'm building a modular input that needs to keep an "API key" secret. This can be done by making the "API key" field a password field in setup.xml.

Snippet from file below

<element name="api_key" type="password" label="API key">
          <view name="edit"/>
          <view name="create"/>
          <key name="exampleText">Private API Key</key>
</element>

However this generates a second confirmation field with the text "Confirm Password" in the form. Given my field is "API Key" can I change this second generated fields text to "Confirm API key" or some how remove the second field?

0 Karma

Flynt
Splunk Employee
Splunk Employee

OK so I messed with this for a minute and came up with this (add it within your block statement in setup.xml)

<text>
    <![CDATA[ <script type="text/javascript">
       $(function() {
           console.log($('label[for*="user_token_id_confirm"]'))
           $('label[for*="user_token_id_confirm"]').html("Confirm User Token")
           $('label[for*="data_token_id_confirm"]').html("Confirm Data Token")
        });
     </script> ]]>
 </text>

Obviously the console.log can be removed, I used that in Chrome's Inspect so I can see I'm getting the right values

I have two input fields in my setup xml, user_token and data_token. Using the jquery selector on the confirm fields to get their labels, I then change the label text to be whatever I want.

Hope this helps.

msivill_splunk
Splunk Employee
Splunk Employee

Do you happen to have the full example to hand? I'm have trouble getting the javascript to be rendered. When I view the html source the javascript is not appearing.

0 Karma

hortonew
Builder
<setup>
  <block title="Title of page">
    <text>All fields are required.</text>
  </block>

  <block title="Add new credentials" endpoint="storage/passwords" entity="_new">
    <input field="name">
      <label>Account ID</label>
      <type>text</type>
    </input>

    <input field="password">
      <label>API Key</label>
      <type>password</type>
    </input>
    <text>
        <![CDATA[ <script type="text/javascript">
            $(function() {
                $('label[for*="password_id_confirm"]').html("Confirm API Key")
             });
        </script> ]]>
    </text>
  </block>
</setup>

msivill_splunk
Splunk Employee
Splunk Employee

Thank you for your response I've moved on from this project and am unlikely to be testing the above solution any time soon. Hopefully, somebody else will find the solution useful and upvote it. Thanks again.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...