Skip to content

Add kubernetes auth method #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Add kubernetes auth method #122

wants to merge 1 commit into from

Conversation

seanmalloy
Copy link

@seanmalloy seanmalloy commented Jul 9, 2018

This is a work in progress. I'm not really a Java programmer. I have not tested this code yet. I'll be testing this code in a next few days.

Any feedback on this pull request would be greatly appreciated.

https://www.vaultproject.io/docs/auth/kubernetes.html

@seanmalloy
Copy link
Author

I have it compiling now. Both of the below commands now execute with out error.

$ ./gradlew build
$ ./gradlew jar

Next step is to test it to see if if works.

@seanmalloy seanmalloy changed the title WIP: Add Kubernetes auth method and allow selecting mount point for GCP Add kubernetes auth method Jul 29, 2018
@seanmalloy
Copy link
Author

seanmalloy commented Jul 29, 2018

I have successfully tested the code, and it is working now. Ready for review.

@seanmalloy
Copy link
Author

@steve-perkins this PR is now ready for review. Let me know if any changes are needed.

@seanmalloy
Copy link
Author

Here is the example program I created for testing this.

/*
 *
 * javac -cp ".:/home/sean/projects/vault-java-driver/build/libs/vault-java-driver-3.1.0.jar" HelloWorld.java 
 * java -cp ".:/home/sean/projects/vault-java-driver/build/libs/vault-java-driver-3.1.0.jar" HelloWorld
 *
 */
import com.bettercloud.vault.*;
import java.nio.file.*;

public class HelloWorld {

    public static void main(String[] args) throws Exception {
	final VaultConfig config = new VaultConfig().address("http://192.168.1.193:8200").build();
	final Vault vault = new Vault(config);

	// read kube jwt from file
	String jwt = new String(Files.readAllBytes(Paths.get("/var/run/secrets/kubernetes.io/serviceaccount/token")));
	System.out.print(jwt);

	// get vault token
	String token = vault.auth().loginByKubernetes("demo", jwt, "foo").getAuthClientToken();

	System.out.print(token);
    }

}

@jetersen
Copy link
Contributor

jetersen commented Apr 16, 2019

@seanmalloy seems #164 is the better approach? reusing what had JWT knowledge 😓

Duplicate of #164

@seanmalloy
Copy link
Author

@Casz I agree #164 looks better, has less code duplication. I'll leave this open, so the project maintainer can decide which approach they like best.

@jetersen
Copy link
Contributor

Duplicate of #164

@steve-perkins
Copy link
Contributor

Thanks, @seanmalloy! We've had a number of PR's for this popular feature! It was ultimately merged as part of #164, and will go out to Maven Central in the next couple of days.

@seanmalloy seanmalloy deleted the kube-auth branch June 18, 2019 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants