Skip to content
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

Allow reading the auth token provided by Kubernetes/OpenShift sidecar #22

Open
dustinmm80 opened this issue Jul 12, 2018 · 2 comments · Fixed by #23
Open

Allow reading the auth token provided by Kubernetes/OpenShift sidecar #22

dustinmm80 opened this issue Jul 12, 2018 · 2 comments · Fixed by #23

Comments

@dustinmm80
Copy link
Contributor

AuthnK8sClient.java

package net.conjur.api.authn;
/*
 * K8S Authn provider 
 * 
 *  This should be used with the cyberark/conjur-kubernetes-authenticator sidecar or init container
 *  The auth token will be published by the sidecar allowing the container app to bypass the authentication step.
 *   
 */
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

public class AuthnK8sClient implements AuthnProvider {

	private Token token;
	
	public AuthnK8sClient(Token token) {
		this.token = token;
	}

	public AuthnK8sClient(Path tokenFilePath) throws IOException {
		this.token = getTokenFromFile(tokenFilePath);
	}
	
	public Token authenticate() {
		return token;
	}

	public Token authenticate(boolean useCachedToken) {
		return this.authenticate();
	}
	
	private Token getTokenFromFile(Path tokenFilePath) throws IOException {
		
		String jsonToken = new String(Files.readAllBytes(tokenFilePath));
		Token token = Token.fromJson(jsonToken);

		return token;
		
	}
}

Ryan Smith @ USAA wrote the attached to retrieve the access token in OpenShift using the Java API. He wanted to contribute this and see it added to the client library. Can that happen?

@jodyhuntatx
Copy link
Member

Smith, Ryan [email protected]
Today, 9:19 AM

Please let me know when the Java API can be updated to support reading the access token directly. If not, we will need to create a custom overlay jar to add the needed support in our environment.

Thanks,

Ryan Smith

Ryan Smith | Software Development Lead | Information Security
Core Security Infrastructure, Enterprise Security Group, USAA

@jodyhuntatx
Copy link
Member

BTW, Ryan needs this for Conjur v5. He has made the code changes and can share those with whomever is on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants