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

feat: make HashiCorp vault authentication extensible #4822

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ronjaquensel
Copy link
Contributor

What this PR changes/adds

Refactors the vault-hashicorp module as outlined in this DR.

Why it does that

To make vault authentication extensible and thus enable using different authentication methods.

Further notes

In addition to what's already mentioned in the DR:

  • created HashicorpVaultTokenRenewService, which now contains the token look-up & renew methods previously located in the health service. I did not add them to the HashicorpVaultTokenRenewTask directly, to keep a separation between the methods for renewing the token and the periodic task triggering the token renewal.
  • created vault-hashicorp-spi, which as of now contains only the HashicorpVaultTokenProvider interface.

Who will sponsor this feature?

me

Linked Issue(s)

Closes #4810
Closes #4751

@ronjaquensel ronjaquensel added enhancement New feature or request refactoring Cleaning up code and dependencies labels Feb 13, 2025
@ronjaquensel ronjaquensel requested a review from ndr-brt February 13, 2025 08:49
@ronjaquensel ronjaquensel self-assigned this Feb 13, 2025
@ronjaquensel ronjaquensel force-pushed the vault-authentication-refactor branch from 1010cbf to 611b5ec Compare February 13, 2025 09:01
Copy link
Member

Choose a reason for hiding this comment

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

I would put this in the spi folder, at the moment all the spis reside there (apart from some dsp ones, that I think they should be put there as well)

* Copyright (c) 2022 Mercedes-Benz Tech Innovation GmbH
* Copyright (c) 2025 Cofinity-X
Copy link
Member

Choose a reason for hiding this comment

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

copyright


private Headers getHeaders() {
private Headers getHeaders(String token) {
Copy link
Member

Choose a reason for hiding this comment

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

given that tokenProvider is a class field, maybe it could be used internally in this method instead of having the token passed every time

assertThat(tokenLookUpResult).isFailed();
assertThat(tokenLookUpResult.getFailureDetail()).isEqualTo("Token look up failed with status 403");
Assertions.assertThat(tokenLookUpResult.getFailureDetail()).isEqualTo("Token look up failed with status 403");
Copy link
Member

Choose a reason for hiding this comment

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

nit: static import


@Provider(isDefault = true)
public HashicorpVaultTokenProvider tokenProvider() {
return new HashicorpVaultTokenProviderImpl(config.token());
Copy link
Member

Choose a reason for hiding this comment

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

given that the token is only used in this extension maybe it could make sense to remove it from the Settings class and put it here as a single @Setting, it would also improve the way it's documented through autodoc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactoring Cleaning up code and dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make HashiCorp vault authentication extensible Refactor HAshicorpHealthService
3 participants