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.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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