@Inject
VaultTransitSecretEngine transit;
transit.encrypt("my_encryption", text);
transit.decrypt("my_encryption", text).asString();
transit.sign("my-sign-key", text);
Transit Key
@Inject
VaultTransitSecretEngine transit;
transit.createKey(KEY_NAME, new KeyCreationRequestDetail().
setExportable(true));
transit.readKey(KEY_NAME);
transit.listKeys();
transit.exportKey(KEY_NAME, VaultTransitExportKeyType.encry
ption, null);
transit.updateKeyConfiguration(KEY_NAME, new KeyConfigReque
stDetail().setDeletionAllowed(true));
transit.deleteKey(KEY_NAME);
Vault TOTP
TOTP secret engine is supported by using
io.quarkus.vault.VaultTOTPSecretEngine class:
@Inject
VaultTOTPSecretEngine vaultTOTPSecretEngine;
CreateKeyParameters createKeyParameters = new CreateKeyPara
meters("Google", "
[email protected]");
createKeyParameters.setPeriod("30m");
/** Generate Key (QR code) */
final Optional<KeyDefinition> myKey = vaultTOTPSecretEngine
.createKey("my_
key_2", createKeyParameters);
/** Generate key number to login */
final String keyCode = vaultTOTPSecretEngine.generateCode(
"my_key_2");
/** Login logic */
boolean valid = vaultTOTPSecretEngine.validateCode("my_key_
2", keyCode);
Vault Provisioning
Vault extension offers façade classes to Vault provisioning
functions:
@Inject
VaultSystemBackendEngine vaultSystemBackendEngine;
@Inject
VaultKubernetesAuthService vaultKubernetesAuthService;
String rules = "path \"transit/*\" {\n" +
" capabilities = [ \"create\", \"read\", \"updat
e\" ]\n" +
"}";
String policyName = "sys-test-policy";
vaultSystemBackendEngine.createUpdatePolicy(policyName, rul
es);
vaultKubernetesAuthService
.createRole(roleName, new VaultKubernetesAuthRole()
.setBoundServiceAccountNames(boundServiceAccountN
ames)
.setBoundServiceAccountNamespaces(boundServiceAcc
ountNamespaces)
.setTokenPolicies(tokenPolicies));
PKI
@Inject
public VaultPKISecretEngine pkiSecretEngine;
GenerateCertificateOptions options = new GenerateCertificat
eOptions();
SignedCertificate signed = pkiSecretEngine.signRequest(
"example-dot-com", csr, options);
return signed.certificate.getData();
Vault conguration properties. Prex quarkus.vault is skipped.
url
Vault server URL
authentication.client-token
Vault token to access
authentication.app-role.role-id
Role Id for AppRole auth
authentication.app-role.secret-id
Secret Id for AppRole auth
authentication.app-role.secret-id-wrapping-token
Wrapping token containing a Secret Id. secret-id and secret-id-
wrapping-token are exclusive.
authentication.userpass.username
Username for userpass auth
authentication.userpass.password
Password for userpass auth
authentication.userpass.password-wrapping-token
Wrapping token containing a password. password and password-
wrapping-token are exclusive.
authentication.kubernetes.role
Kubernetes authentication role
authentication.kubernetes.jwt-token-path
Location of the le containing the Kubernetes JWT token
renew-grace-period
Renew grace period duration (default: 1H)
secret-config-cache-period
Vault cong source cache period (default: 10M)
secret-config-kv-path
Vault path in kv store. List of paths is supported in CSV
log-confidentiality-level
Used to hide condential infos. low, medium, high (default:
medium)
kv-secret-engine-version
Kv secret engine version (default: 1)
kv-secret-engine-mount-path Kv secret engine path (default: secret)
tls.skip-verify
Allows to bypass certicate validation on TLS communications
(default: false)
tls.ca-cert
Certicate bundle used to validate TLS communications
tls.use-kubernetes-ca-cert
TLS will be active (default: true)
connect-timeout
Tiemout to establish a connection (default: 5S)
read-timeout
Request timeout (default: 1S)
credentials-provider."credentials-provider".database-credentials-
role
Database credentials role
credentials-provider."credentials-provider".kv-path
A path in vault kv store, where we will nd the kv-key
credentials-provider."credentials-provider".kv-key
Key name to search in vault path kv-path (default: password)
DevServices
When testing or running in dev mode Quarkus can even provide you
with a zero cong Vault out of the box.