Skip to content

Commit

Permalink
feat: implement automatic hashicorp token renewal (eclipse-edc#3782)
Browse files Browse the repository at this point in the history
* feat: add PrefixMonitor (eclipse-edc#3510)

* feat: add token rotation mechanism

* test: adding tests for hashicorp token rotation

* fix: fix checkstyle errors

* fix: set empty list when policies null

* docs: update DEPENDENCIES

* fix: pr comments

* fix: pr comments

* fix: pr comments

* add custom retry mechanism to token renewal

* merge upstream main

* minor fixes

* extract hashicorp config value validation into separate class

* checkstyle fixes

* remove vault timeout config

* clean up

* added ConfigImplTest test for double config

* remove root token property from token look up data

* use in-built retry mechanism of EdcHttpClient for token operations

* using single thread executor for hashicorp client

* remove retry config from HashicorpVaultConfig

* revert config impl changes

* revert SettingResolver changes

* test call of FallbackFactories.retryWhenStatusIsNotIn(..) with static mocks

* implement custom Fallback factory for hashicorp client

* replace token dto classes by map<string, object>

* merge upstream

* update pr comments

* update pr comments

* update pr comments

* clean up merge

* merge main into feature branch
  • Loading branch information
hamidonos authored Mar 20, 2024
1 parent 964e40b commit 3cde990
Show file tree
Hide file tree
Showing 27 changed files with 1,641 additions and 1,092 deletions.

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024 Mercedes-Benz Tech Innovation GmbH
*
* 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:
* Mercedes-Benz Tech Innovation GmbH - Implement automatic Hashicorp Vault token renewal
*
*/

package org.eclipse.edc.vault.hashicorp;

import dev.failsafe.Fallback;
import okhttp3.Request;
import okhttp3.Response;
import org.eclipse.edc.spi.http.FallbackFactory;

import static org.eclipse.edc.spi.http.FallbackFactories.retryWhenStatusIsNotIn;

/**
* Implements a {@link Fallback}factory for requests executed against the Hashicorp Vault.
*
* @see <a href="https://developer.hashicorp.com/vault/api-docs">Hashicorp Vault Api</a> for more information on retryable error codes.
*/
public class HashicorpVaultClientFallbackFactory implements FallbackFactory {

private static final int[] NON_RETRYABLE_STATUS_CODES = {200, 204, 400, 403, 404, 405};

@Override
public Fallback<Response> create(Request request) {
return retryWhenStatusIsNotIn(NON_RETRYABLE_STATUS_CODES).create(request);
}
}
Loading

0 comments on commit 3cde990

Please sign in to comment.