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

docs: adds decision record for HashiCorp Vault auth refactor #4720

Closed

Conversation

SaschaIsele
Copy link
Contributor

What this PR changes/adds

This PR adds a decision record that outlines a refactor of the authentication inside the vault-hashicorp extension.

Why it does that

Currently, the only possible authentication method for HashiCorp Vault is token authentication which is hardcoded into the extension.
To pave the way for additonal authentication methods, the authentication of vault-hashicorp extension needs to be extensible.
This PR outlines the changes needed to achieve interchangeable authentication.

Further notes

This version of the decision record removes the registry and spi in favor of a default implementation that can be overwritten.

Linked Issue(s)

Closes #4672
Related discussion: #4374
Previous closed PR: #4673

@ndr-brt ndr-brt requested a review from a team January 14, 2025 08:07
Copy link
Contributor

@jimmarino jimmarino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments, but otherwise I'm fine with this.

The sole common point between the authentication methods is the ability to provide a `client_token` that can be used to authenticate with HashiCorp Vault.

```java
public interface HashicorpVaultAuth {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is not intuitive. It should reflect what role it provides.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which name would be more intuitive?
Only other fitting name that comes to mind for me would be HashicorpVaultTokenProvider.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That name is better IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name has been adjusted.


```java
@NotNull
private Headers getHeaders() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first look, I would prefer the token to be passed into this function (also valueAuth to be renamed because it is not intuitive) rather than computed from a member at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing the token into this function instead of retrieving it inside would lead to duplicate code in four places.
While it would only be one line, the call to retrieve the token has to be made either way inside the public methods of the HashicorpVaultClient.
Doing it during header generation in a central place seems the most sensible to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm talking about the vaultAuth.vaultToken() call. That value can be passed to the method instead of having the method rely on a class member. I generally don't like getXXX methods that rely on members since it is not apparent what the inputs of the method are.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the token to the parameters of getHeaders.

@SaschaIsele SaschaIsele added the documentation Improvements or additions to documentation label Jan 14, 2025
@SaschaIsele SaschaIsele requested a review from jimmarino January 17, 2025 03:14
Copy link
Contributor

@jimmarino jimmarino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please distinguish class names better before I proceed with a further review? Specifically, HashicorpVaultAuthTokenProvider and HashicorpVaultTokenAuth are extremely confusing.

@SaschaIsele
Copy link
Contributor Author

SaschaIsele commented Jan 22, 2025

@jimmarino did a pass for the class names.
HashicorpVaultAuthTokenProvider was renamed to HashicorpVaultAuthClientTokenProvider to make it readily apparent, what it provides.
HashicorpVaultTokenAuth was renamed to HashicorpVaultAuthTokenImpl to signify it as the implementation for the token authentication method of HashiCorp Vault.

Also saw the PR #4749 from @paullatzelsperger which already takes care of the refactoring part for the current token authentication and would reroute the changes specified for the HashicorpVaultClientto the HashicorpVault.java and HashicorpVaultHealthService, depending on which PR gets merged first.

@jimmarino
Copy link
Contributor

jimmarino commented Jan 22, 2025

@jimmarino did a pass for the class names. HashicorpVaultAuthTokenProvider was renamed to HashicorpVaultAuthClientTokenProvider to make it readily apparent, what it provides. HashicorpVaultTokenAuth was renamed to HashicorpVaultAuthTokenImpl to signify it as the implementation for the token authentication method of HashiCorp Vault.

Also saw the PR #4749 from @paullatzelsperger which already takes care of the refactoring part for the current token authentication and would reroute the changes specified for the HashicorpVaultClientto the HashicorpVault.java and HashicorpVaultHealthService, depending on which PR gets merged first.

Sorry, but these names are completely confusing and do not align. For example:

@Provider(isDefault = true)
public HashicorpVaultAuthClientTokenProvider HashicorpVaultAuthClientTokenProvider() {
    return new HashicorpVaultAuthTokenImpl();
}

This makes what should be simple code difficult to follow and is a sign that the concepts underpinning this PR are not fully thought through. I think you should go back and clarify this PR before asking the committers to review it again.

@paullatzelsperger
Copy link
Member

paullatzelsperger commented Jan 22, 2025

@SaschaIsele

Also saw the PR #4749 from @paullatzelsperger which already takes care of the refactoring part for the current token authentication and would reroute the changes specified for the HashicorpVaultClientto the HashicorpVault.java and HashicorpVaultHealthService, depending on which PR gets merged first.

that PR just cleans up a - frankly speaking - poor implementation of the HashicorpVault, and it adds a facility to do remote signing/verifying and key rotation.

Copy link
Member

@paullatzelsperger paullatzelsperger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have two major gripes with this PR:

  1. succinctness: a lot of stuff is explained, that is already covered by documentation. This would make the DR much shorter and more concise.
  2. design: a few services seem to emerge from the Hashicorp Vault area (again, PR feat: implement Hashicorp Vault signing service #4749):
  • a secure key-value store (the "vault") -> HashicorpVault
  • a signing service HashicorpSignatureService
  • a health check service HashicorpHealthService
    all of these services share the same auth method. I think this DR should mention that.

@SaschaIsele
Copy link
Contributor Author

@jimmarino the concepts for the authentication interface are taken straight from HashiCorp Vault.
The interface exists to provide the client_token needed for authentication with HashiCorp Vault and the authentication method currently implemented by the extension is called Token auth method.
While the naming can be confusing, it is the terminology used by HashiCorp Vault.

@SaschaIsele
Copy link
Contributor Author

@paullatzelsperger I cut a few explanations to make the decision record more concise, incorporated the changes from #4749 and made sure to mention the different services that use the authentication method.
Let me know how it looks to you now.

@jimmarino
Copy link
Contributor

@jimmarino the concepts for the authentication interface are taken straight from HashiCorp Vault. The interface exists to provide the client_token needed for authentication with HashiCorp Vault and the authentication method currently implemented by the extension is called Token auth method. While the naming can be confusing, it is the terminology used by HashiCorp Vault.

Names like HashicorpVaultAuthTokenImpl are not terminology used by Hashicorp Vault. Please review the previous example I raised and others like it in the PR. Until those are cleaned up and you indicate as such, I will not review or lift my request for changes to this PR.

@SaschaIsele SaschaIsele force-pushed the docs/kubernetes_auth_DR branch from 89353e1 to 3f8aadf Compare January 29, 2025 09:01
@SaschaIsele
Copy link
Contributor Author

SaschaIsele commented Jan 30, 2025

Kept the naming simple with the interface HashicorpVaultTokenProvider and its default implementation HashicorpVaultTokenProviderImpl which are the only two new classes.
Added a very brief explanation for HashicorpVaultTokenProviderImpl and kept the DR more concise overall.

Copy link

github-actions bot commented Feb 6, 2025

This pull request is stale because it has been open for 7 days with no activity.

@ronjaquensel
Copy link
Contributor

Superseded by #4802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation stale Open for x days with no activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: HashiCorp Vault authentication refactor decision record
4 participants