cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can you use Credential Vault content in python extensions

r_weber
DynaMight Champion
DynaMight Champion

It seems impossible to pass credential vault content (e.g. user/password values) to a python extension so that it can be used in code.

I came across this post which describes how to add credential vault UI configuration, however this doesn't pass the actual content to the python extension, only the VAULT-ID is passed.

Does anyone know how I can e.g. get the username/password into my custom python extension?

Thanks

Certified Dynatrace Master, Dynatrace Partner - 360Performance.net
1 REPLY 1

calfanonerey
Observer

hey @r_weber I was just running into this for an api token I'm storing. the post by @Julius_Loman  on this thread
https://community.dynatrace.com/t5/Extensions/Send-a-credential-from-credential-vault-to-extension/m...
did it for me. It all has to do with the activationSchema.json. Here's what he had configured:
it looks to me the key here is to have the credentialVaultId entry and then subsequent values have the property 

useCredentialVault
{
  "types": {
    "dynatrace.datasource.python:credential_vault-endpoint": {
      "type": "object",
      "displayName": "Credential_vault Endpoint",
      "summaryPattern": "Credential_vault",
      "properties": {
        "useCredentialVault": {
          "displayName": "Use credential vault",
          "type": "boolean",
          "nullable": false,
          "default": true,
          "maxObjects": 1
        },
        "credentialVaultId": {
          "displayName": "Select Vault credentials",
          "nullable": true,
          "type": "text",
          "subType": "credential",
          "referencedType": "USERNAME_PASSWORD",
          "maxObjects": 1,
          "precondition": {
            "type": "EQUALS",
            "property": "useCredentialVault",
            "expectedValue": true
          },
          "constraints": [
            {
              "type": "NOT_BLANK"
            }
          ]
        },
        "username": {
          "displayName": "User Name",
          "type": "text",
          "nullable": false,
          "default": "",
          "precondition": {
            "type": "EQUALS",
            "property": "useCredentialVault",
            "expectedValue": false
          },
          "constraints": [
            {
              "type": "LENGTH",
              "minLength": 1,
              "maxLength": 500
            }
          ],
          "maxItems": 1
        },
        "password": {
          "displayName": "Password",
          "type": "secret",
          "nullable": false,
          "default": "",
          "precondition": {
            "type": "EQUALS",
            "property": "useCredentialVault",
            "expectedValue": false
          },
          "constraints": [
            {
              "type": "LENGTH",
              "minLength": 1,
              "maxLength": 500
            }
          ],
          "maxItems": 1
        }

      }
    },
    "pythonRemote": {
      "type": "object",
      "properties": {
        "endpoints": {
          "displayName": "Credential_vault endpoint",
          "type": "list",
          "items": {
            "type": {
              "$ref": "#/types/dynatrace.datasource.python:credential_vault-endpoint"
            }
          },
          "nullable": false,
          "minItems": 1,
          "maxItems": 100,
          "metaData": {
            "addItemButton": "Add endpoint"
          }
        }
      }
    },
    "pythonLocal": {
      "type": "object",
      "properties": {
        "endpoints": {
          "displayName": "Credential_vault endpoint",
          "type": "list",
          "items": {
            "type": {
              "$ref": "#/types/dynatrace.datasource.python:credential_vault-endpoint"
            }
          },
          "nullable": false,
          "minItems": 1,
          "maxItems": 100,
          "metaData": {
            "addItemButton": "Add endpoint"
          }
        }
      }
    }
  },
  "dynatrace": "1",
  "description": "credential_vault configuration",
  "schemaId": "python-extension.activation",
  "displayName": "credential_vault configuration",
  "ownerProductManagement": "dynatrace",
  "ownerDevelopment": "dynatrace",
  "maturity": "GENERAL_AVAILABILITY",
  "allowedScopes": [
    "tenant"
  ],
  "multiObject": false,
  "properties": {
    "pythonLocal": {
      "displayName": "Python Local Extension",
      "type": {
        "$ref": "#/types/pythonLocal"
      }
    },
    "pythonRemote": {
      "displayName": "Python Remote Extension",
      "type": {
        "$ref": "#/types/pythonRemote"
      }
    }
  }
}

 

Featured Posts