Skip to content

Commit 72eba45

Browse files
authored
Add overloading method loginByKubernetes() with custom authPath (#29)
Signed-off-by: dttung2905 <[email protected]>
1 parent f4c4da7 commit 72eba45

File tree

1 file changed

+25
-0
lines changed
  • src/main/java/io/github/jopenlibs/vault/api

1 file changed

+25
-0
lines changed

src/main/java/io/github/jopenlibs/vault/api/Auth.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,31 @@ public AuthResponse loginByKubernetes(final String role, final String jwt)
10931093
return loginByJwt("kubernetes", role, jwt);
10941094
}
10951095

1096+
/**
1097+
* Basic login operation to authenticate to a kubernetes backend with custom path. Example usage:
1098+
*
1099+
* <blockquote>
1100+
*
1101+
* <pre>{@code
1102+
* final AuthResponse response =
1103+
* vault.auth().loginByKubernetes("dev", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "customAuthPath");
1104+
*
1105+
* final String token = response.getAuthClientToken();
1106+
* }</pre>
1107+
* </blockquote>
1108+
*
1109+
* @param role The kubernetes role used for authentication
1110+
* @param jwt The JWT token for the role, typically read from
1111+
* /var/run/secrets/kubernetes.io/serviceaccount/token
1112+
* @param authPath The Authentication Path for Vault
1113+
* @return The auth token, with additional response metadata
1114+
* @throws VaultException If any error occurs, or unexpected response received from Vault
1115+
*/
1116+
public AuthResponse loginByKubernetes(final String role, final String jwt, final String authPath)
1117+
throws VaultException {
1118+
return loginByJwt("kubernetes", role, jwt, authPath);
1119+
}
1120+
10961121
/**
10971122
* <p>Basic login operation to authenticate using Vault's TLS Certificate auth backend.
10981123
* Example usage:</p>

0 commit comments

Comments
 (0)