Vault Service
Vault Service
Vault Service provides access to encrypted storage.
To use vault service, you should inject VaultService object into the task.
@ApTaskEntry(name = "Vault task") @Slf4j public class VaultTask extends ApTaskBase { @Inject VaultService vaultService; }
At the time, vault service provides only getter methods
Store credentials
Typically in vault service we store user credentials. In order to put credentials in vault service locally (standalone configuration), they should be provided as decoded in Base64 JSON map containing user and password keys e.g.:
If you want to store credentials with user name "admin" and password "123456", you should create the following JSON:
{ "user": "admin", "password": "123456" }
Then provide some alias name. Finally your "resources/vault.properties" file will contain the following key-value pair:
mail.user={"user": admin", "password": "123456"}
Example of retrieving user credentials:
SecretCredentials secrets = vaultService.getSecret("mail.user", SecretCredentials.class); log.info("'mail.user' user:{} password:{}", secrets.getUser(), secrets.getPassword());
Store any string
There's also possibility to store any string value in secret value.
my.alias=SGVsbG8gZnJvbSBzZWNyZXQgdmF1bHQh
Example of retrieving string value from vault service:
String myValue = vaultService.getSecret("my.alias", String.class);
In node configuration secrets are persisted in HashiCorp vault backed by PostgresSQL database.
In this case secret entries are added manually from secret-vault page of Control Server or using Control Server API
Full example: