From 72eba45fb351183a90bca3bf4aed6b63ac284d1f Mon Sep 17 00:00:00 2001 From: Dao Thanh Tung Date: Mon, 17 Apr 2023 04:43:17 +0800 Subject: [PATCH] Add overloading method loginByKubernetes() with custom authPath (#29) Signed-off-by: dttung2905 --- .../io/github/jopenlibs/vault/api/Auth.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/io/github/jopenlibs/vault/api/Auth.java b/src/main/java/io/github/jopenlibs/vault/api/Auth.java index d026a984..3179dbe0 100644 --- a/src/main/java/io/github/jopenlibs/vault/api/Auth.java +++ b/src/main/java/io/github/jopenlibs/vault/api/Auth.java @@ -1093,6 +1093,31 @@ public AuthResponse loginByKubernetes(final String role, final String jwt) return loginByJwt("kubernetes", role, jwt); } + /** + * Basic login operation to authenticate to a kubernetes backend with custom path. Example usage: + * + *
+ * + *
{@code
+     * final AuthResponse response =
+     *     vault.auth().loginByKubernetes("dev", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "customAuthPath");
+     *
+     * final String token = response.getAuthClientToken();
+     * }
+ *
+ * + * @param role The kubernetes role used for authentication + * @param jwt The JWT token for the role, typically read from + * /var/run/secrets/kubernetes.io/serviceaccount/token + * @param authPath The Authentication Path for Vault + * @return The auth token, with additional response metadata + * @throws VaultException If any error occurs, or unexpected response received from Vault + */ + public AuthResponse loginByKubernetes(final String role, final String jwt, final String authPath) + throws VaultException { + return loginByJwt("kubernetes", role, jwt, authPath); + } + /** *

Basic login operation to authenticate using Vault's TLS Certificate auth backend. * Example usage: