-
Notifications
You must be signed in to change notification settings - Fork 267
feat: make HashiCorp vault authentication extensible #4822
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
Merged
ronjaquensel
merged 14 commits into
eclipse-edc:main
from
Cofinity-X:vault-authentication-refactor
Feb 21, 2025
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
daf033c
feat(vault): refactors vault authentication to be interchangeable
SaschaIsele 25b94de
feat(vault): fixes two tests
SaschaIsele fe5c78b
docs: add license headers & Javadoc
ronjaquensel 7ef6ecd
refactor: move token renewal methods to separate service
ronjaquensel cf76c6b
chore: add missing annotations
ronjaquensel 8c1e17a
refactor: extract token provider interface to spi module
ronjaquensel a665450
test: add test for token provider impl
ronjaquensel 331b2e8
refactor: create auth extension
ronjaquensel 177f30f
chore: clean-up
ronjaquensel 611b5ec
chore: checkstyle
ronjaquensel 468eb65
chore: PR comments
ronjaquensel eb832cc
chore: PR comments
ronjaquensel 1ba4f76
chore: PR comments
ronjaquensel aadc4e0
fix: error logging (CodeQL)
ronjaquensel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
extensions/common/vault/hashicorp/vault-hashicorp-spi/build.gradle.kts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2025 Cofinity-X | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Cofinity-X - initial API and implementation | ||
* | ||
*/ | ||
|
||
plugins { | ||
`java-library` | ||
} | ||
|
||
dependencies { | ||
api(project(":spi:common:core-spi")) | ||
} |
33 changes: 33 additions & 0 deletions
33
...i/src/main/java/org/eclipse/edc/vault/hashicorp/spi/auth/HashicorpVaultTokenProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2025 Cofinity-X | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Cofinity-X - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.vault.hashicorp.spi.auth; | ||
|
||
import org.eclipse.edc.runtime.metamodel.annotation.ExtensionPoint; | ||
|
||
/** | ||
* Provides a token for authentication against the HashiCorp vault. | ||
*/ | ||
@FunctionalInterface | ||
@ExtensionPoint | ||
public interface HashicorpVaultTokenProvider { | ||
|
||
/** | ||
* Obtains and returns the authentication token for the HashiCorp vault. | ||
* | ||
* @return the authentication token | ||
*/ | ||
String vaultToken(); | ||
|
||
} |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
...main/java/org/eclipse/edc/vault/hashicorp/auth/HashicorpVaultAuthenticationExtension.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2025 Cofinity-X | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Cofinity-X - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.vault.hashicorp.auth; | ||
|
||
import org.eclipse.edc.runtime.metamodel.annotation.Configuration; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Extension; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Provider; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.vault.hashicorp.client.HashicorpVaultSettings; | ||
import org.eclipse.edc.vault.hashicorp.spi.auth.HashicorpVaultTokenProvider; | ||
|
||
@Extension(value = HashicorpVaultAuthenticationExtension.NAME) | ||
public class HashicorpVaultAuthenticationExtension implements ServiceExtension { | ||
|
||
public static final String NAME = "Hashicorp Vault Authentication"; | ||
|
||
@Configuration | ||
private HashicorpVaultSettings config; | ||
|
||
@Provider(isDefault = true) | ||
public HashicorpVaultTokenProvider tokenProvider() { | ||
return new HashicorpVaultTokenProviderImpl(config.token()); | ||
ronjaquensel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...p/src/main/java/org/eclipse/edc/vault/hashicorp/auth/HashicorpVaultTokenProviderImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2025 Cofinity-X | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Cofinity-X - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.vault.hashicorp.auth; | ||
|
||
import org.eclipse.edc.vault.hashicorp.spi.auth.HashicorpVaultTokenProvider; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Implements the token auth method of the HashiCorp vault. Returns the configured token. | ||
*/ | ||
public class HashicorpVaultTokenProviderImpl implements HashicorpVaultTokenProvider { | ||
|
||
private final String token; | ||
|
||
public HashicorpVaultTokenProviderImpl(String token) { | ||
requireNonNull(token, "Vault token must not be null"); | ||
this.token = token; | ||
} | ||
|
||
@Override | ||
public String vaultToken() { | ||
return token; | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.