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
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...