4.2

You are viewing documentation for an older version of Lenses.io View latest documentation here

Hashicorp Vault

Secure secrets in Hashicorp Vault and use them in Kafka Connect.

Add the plugin to the worker classloader isolation via the plugin.path option:

plugin.path=/usr/share/connectors,/opt/secret-providers

Multiple authentication methods are support:

  • approle
  • userpass
  • kubernetes
  • cert
  • token
  • ldap
  • gcp
  • awsiam
  • jwt
  • github

Configuring the plugin 


NameDescription
file.dirThe base location for any files to be stored
vault.auth.methodAvailable values are approle, userpass, kubernetes, cert, token, ldap, gcp, awsiam, jwt, github, token
vault.addrAddress of the Vault server
vault.tokenUse when ‘vault.auth.method’ is ‘token’ to specify the token value
vault.namespaceSet a global namespace to the Vault server instance. Requires Vault Enterprise Pro
vault.pemFile containing the Vault Server certificate content as string
vault.client.pemFile containing the Client certificate string content as string
vault.engine.versionKV Secrets Engine version of the Vault server instance. Default is 2
vault.ssl.truststore.locationThe location of the trust store file
vault.ssl.keystore.locationThe location of the key store file
vault.ssl.keystore.passwordThe password for the key store file
app.role.idUse when vault.auth.method is approle or kubernetes to specify the Vault App role id
app.role.secret.idUse when vault.auth.method is approle tp specify the Vault App role name secret id
usernameUse when vault.auth.method is userpass to specify the username to connect to Vault
passwordUse when vault.auth.method is userpass to specify the password to connect to Vault
mountUse when vault.auth.method is userpass to specify the mount name of the userpass authentication back end
ldap.usernameUse when vault.auth.method is ldap to specify the LDAP username to connect to Vault with
ldap.passwordUse when vault.auth.method is ldap to specify the LDAP password to connect to Vault with
mountUse when vault.auth.method is ldap to specify the mount name of the ldap authentication back end
jwt.roleUse when vault.auth.method is jwt to specify the role the JWT token belongs to
jwt.providerUse when vault.auth.method is jwt to specify the provider of the JWT token
jwtUse when vault.auth.method is jwt to specify the JWT token
gcp.roleUse when vault.auth.method is gcp to specify the gcp role used for authentication
gcp.jwtUse when vault.auth.method is gcp to specify the JWT token
cert.mountUse when vault.auth.method is cert to specify the mount name of the cert authentication back end
github.tokenUse when vault.auth.method is github to specify the github app-id to use for authentication
github.mountUse when vault.auth.method is github to specify the mount name of the github authentication back end
kubernetes.roleUse when vault.auth.method is kubernetes to specify the kubernetes role for authentication
kubernetes.token.pathUse when vault.auth.method is kubernetes to specify the path to the service account token . Default is /var/run/secrets/kubernetes.io/serviceaccount/token
aws.roleUse when vault.auth.method is awsiam.
Name of the role to login. If role is not specified, the login endpoint uses the role bearing the name of the AMI ID of the EC2 instance or if using the ec2 auth method the friendly name (i.e., role name or username) of the IAM authenticated principal
aws.request.urlUse when vault.auth.method is awsiam.
PKCS7 signature of the identity document with all n characters removed. Base64-encoded HTTP URL used in the signed request (i.e. base64-encoding of https://sts.amazonaws.com) as most requests will probably use POST with an empty URI
aws.request.bodyUse when vault.auth.method is awsiam.
Base64-encoded body of the signed request i.e. base64 of Action=GetCallerIdentity&Version=2011-06-15
aws.request.headersUse when vault.auth.method is awsiam to specify any request headers
aws.mountUse when vault.auth.method is awsiam. The AWS auth mount. Default is “aws”

Example Worker Properties

config.providers=vault
config.providers.vault.class=io.lenses.connect.secrets.providers.VaultSecretProvider
config.providers.vault.param.vault.addr=http://localhost:8200
config.providers.vault.param.vault.auth.method=token
config.providers.vault.param.vault.token=my-token
config.providers.vault.param.file.dir=/connector-files/vault

Usage 

To use this provider in a connector, reference the Hashicorp Vault containing the secret and the key name for the value of the connector property.

The indirect reference is in the form ${provider:path:key} where:

  • provider is the name of the provider in the worker property file set above
  • path is the path of the secret in Hashicorp Vault
  • key is the name of the secret key in secret to retrieve. Vault can store multiple keys under a path.

For example, if we store two secrets as keys:

  • my_username_key with the value lenses and
  • my_password_key with the value my-secret-password

in a secret called secret/my-vault-secret we would set:

name=my-sink
class=my-class
topics=mytopic
username=${vault:secret/my-vault-secret:my_username_key}
password=${vault:secret/my-vault-secret:my_password_key}

This would resolve at runtime to:

name=my-sink
class=my-class
topics=mytopic
username=lenses
password=my-secret-password

Data encoding 

The provider handles the following types:

  • utf_8
  • base64

The provider will look for keys prefixed with:

  • UTF8
  • UTF_FILE
  • BASE64
  • BASE64_FILE

The UTF8 means the value returned is the string retrieved for the secret key. The BASE64 means the value returned is the base64 decoded string retrieved for the secret key.

If the value for the tag is UTF8_FILE the string contents are written to a file. The returned value from the connector configuration key will be the location of the file. The file location is determined by the file.dir configuration option given to the provider via the Connect worker.properties file.

If the value for the tag is BASE64_FILE the string contents are based64 decoded and are written to a file. The returned value from the connector configuration key will be the location of the file. For example, if a connector needs a PEM file on disk set, this as the prefix as BASE64_FILE. The file location is determined by the file.dir configuration option given to the provider via the Connect worker.properties file.

If no prefix is found the contents of the secret string are returned.