Class KubernetesAuth

java.lang.Object
codes.grow.packages.vault.KubernetesAuth
All Implemented Interfaces:
AuthMethod

public final class KubernetesAuth extends Object implements AuthMethod
Kubernetes login: POST auth/<mount>/login {role, jwt} with the service account token read from jwtPath (default "/var/run/secrets/kubernetes.io/serviceaccount/token") at login time.
  • Field Details

    • DEFAULT_JWT_PATH

      public static final String DEFAULT_JWT_PATH
      Default service account token path inside a pod.
      See Also:
  • Constructor Details

    • KubernetesAuth

      public KubernetesAuth(String role)
      Creates the method on mount kubernetes with the default token path.
      Parameters:
      role - role name
    • KubernetesAuth

      public KubernetesAuth(String role, String jwtPath)
      Creates the method on mount kubernetes.
      Parameters:
      role - role name
      jwtPath - service account token file
    • KubernetesAuth

      public KubernetesAuth(String role, Path jwtPath, String mount)
      Creates the method.
      Parameters:
      role - role name
      jwtPath - service account token file
      mount - auth mount path
  • Method Details

    • withJwt

      public static KubernetesAuth withJwt(String role, Secret jwt, String mount)
      Creates the method with an explicit service account token instead of a file.
      Parameters:
      role - role name
      jwt - service account token
      mount - auth mount path
      Returns:
      the method
      Throws:
      ConfigException - when the JWT is empty
    • jwtPath

      public Path jwtPath()
      Returns the service account token path.
      Returns:
      the path
    • method

      public String method()
      Description copied from interface: AuthMethod
      Returns the method name, e.g. approle.
      Specified by:
      method in interface AuthMethod
      Returns:
      the name
    • login

      public CompletableFuture<AuthInfo> login(LoginContext context)
      Description copied from interface: AuthMethod
      Performs the login.
      Specified by:
      login in interface AuthMethod
      Parameters:
      context - login helpers of the client
      Returns:
      a future with the auth info
    • toString

      public String toString()
      Overrides:
      toString in class Object