forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request envoyproxy#4 from mangchiandjjoe/sds_dynamic_secret
Sds dynamic secret
- Loading branch information
Showing
72 changed files
with
1,701 additions
and
137 deletions.
There are no files selected for viewing
This file contains 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,30 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "secret_interface", | ||
hdrs = ["secret.h"], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "secret_callbacks_interface", | ||
hdrs = ["secret_callbacks.h"], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "secret_manager_interface", | ||
hdrs = ["secret_manager.h"], | ||
deps = [ | ||
":secret_callbacks_interface", | ||
":secret_interface", | ||
"@envoy_api//envoy/api/v2/auth:cert_cc", | ||
"@envoy_api//envoy/api/v2/core:config_source_cc", | ||
], | ||
) |
This file contains 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,41 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "envoy/common/pure.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
class Secret; | ||
|
||
typedef std::shared_ptr<Secret> SecretSharedPtr; | ||
|
||
/** | ||
* An instance of the secret. | ||
*/ | ||
class Secret { | ||
public: | ||
virtual ~Secret() {} | ||
|
||
enum SecretType { TLS_CERTIFICATE }; | ||
|
||
/** | ||
* @return a name of the secret. | ||
*/ | ||
virtual const std::string& name() const PURE; | ||
|
||
/** | ||
* @return a type of the secret instance. | ||
*/ | ||
virtual SecretType type() const PURE; | ||
|
||
/** | ||
* @return true if secret contains same values. Otherwise returns false. | ||
*/ | ||
virtual bool equalTo(const SecretSharedPtr& secret) const PURE; | ||
}; | ||
|
||
} // namespace Secret | ||
} // namespace Envoy |
This file contains 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,22 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "envoy/common/pure.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
/** | ||
* Callbacks invoked by a secret manager. | ||
*/ | ||
class SecretCallbacks { | ||
public: | ||
virtual ~SecretCallbacks() {} | ||
|
||
virtual void onAddOrUpdateSecret() PURE; | ||
}; | ||
|
||
} // namespace Secret | ||
} // namespace Envoy |
This file contains 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,59 @@ | ||
#pragma once | ||
|
||
#include "envoy/api/v2/auth/cert.pb.h" | ||
#include "envoy/api/v2/core/config_source.pb.h" | ||
#include "envoy/secret/secret.h" | ||
#include "envoy/secret/secret_callbacks.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
/** | ||
* A manager for all static secrets | ||
*/ | ||
class SecretManager { | ||
public: | ||
virtual ~SecretManager() {} | ||
|
||
/** | ||
* add or update secret grouped by type. | ||
* @param sdsConfigSourceHash a hash string of normalized config source. If it is empty string, | ||
* find secret from the static secrets. | ||
* @param secret a shared_ptr of an implementation of Secret. | ||
*/ | ||
virtual void addOrUpdateSecret(const std::string& sdsConfigSourceHash, | ||
const envoy::api::v2::auth::Secret& secret) PURE; | ||
|
||
/**const envoy::api::v2::auth::Secret& secret | ||
* @param sdsConfigSourceHash hash string of normalized config source. | ||
* @param name a name of the secret | ||
* @return the secret in given type. Returns nullptr if the secret is not found. | ||
*/ | ||
virtual const SecretSharedPtr findSecret(Secret::SecretType type, | ||
const std::string& sdsConfigSourceHash, | ||
const std::string& name) const PURE; | ||
|
||
/** | ||
* Add or update SDS config source. SecretManager start downloading secrets from registered | ||
* config source. | ||
* | ||
* @param sdsConfigSource a protobuf message object contains SDS config source. | ||
* @return a hash string of normalized config source | ||
*/ | ||
virtual std::string | ||
addOrUpdateSdsService(const envoy::api::v2::core::ConfigSource& sdsConfigSource) PURE; | ||
|
||
/** | ||
* Register callback function when on secret were updated. | ||
* | ||
* @param hash Hash code of ConfigSource | ||
* @param secret updated SecretSharedPtr | ||
* @param callback Callback function | ||
*/ | ||
virtual void registerSecretCallbacks(const std::string config_source_hash, | ||
const std::string secret_name, | ||
SecretCallbacks& callback) PURE; | ||
}; | ||
|
||
} // namespace Secret | ||
} // namespace Envoy |
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
#pragma once | ||
|
||
#include "envoy/service/discovery/v2/ads.pb.h" | ||
#include "envoy/service/discovery/v2/sds.pb.h" | ||
#include "envoy/service/ratelimit/v2/rls.pb.h" | ||
|
||
namespace Envoy { | ||
|
||
// Hack to force linking of the service: https://github.com/google/protobuf/issues/4221. | ||
// This file should be included ONLY if this hack is required. | ||
const envoy::service::discovery::v2::AdsDummy _ads_dummy; | ||
const envoy::service::discovery::v2::SdsDummy _sds_dummy; | ||
const envoy::service::ratelimit::v2::RateLimitRequest _rls_dummy; | ||
} // namespace Envoy |
This file contains 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 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,61 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "secret_manager_util", | ||
hdrs = ["secret_manager_util.h"], | ||
deps = [ | ||
"//source/common/json:json_loader_lib", | ||
"@envoy_api//envoy/api/v2/core:config_source_cc", | ||
], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "secret_manager_impl_lib", | ||
srcs = ["secret_manager_impl.cc"], | ||
hdrs = ["secret_manager_impl.h"], | ||
deps = [ | ||
":sds_api_lib", | ||
":secret_manager_util", | ||
"//include/envoy/secret:secret_manager_interface", | ||
"//include/envoy/server:instance_interface", | ||
"//source/common/ssl:tls_certificate_config_impl_lib", | ||
], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "sds_api_lib", | ||
srcs = ["sds_api.cc"], | ||
hdrs = ["sds_api.h"], | ||
deps = [ | ||
":sds_subscription_lib", | ||
":secret_manager_util", | ||
"//include/envoy/config:subscription_interface", | ||
"//include/envoy/secret:secret_interface", | ||
"//include/envoy/secret:secret_manager_interface", | ||
"//include/envoy/server:instance_interface", | ||
"//source/common/config:resources_lib", | ||
"//source/common/config:subscription_factory_lib", | ||
"//source/common/ssl:tls_certificate_config_impl_lib", | ||
], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "sds_subscription_lib", | ||
srcs = ["sds_subscription.cc"], | ||
hdrs = ["sds_subscription.h"], | ||
deps = [ | ||
"//include/envoy/config:subscription_interface", | ||
"//source/common/config:lds_json_lib", | ||
"//source/common/config:utility_lib", | ||
"//source/common/http:rest_api_fetcher_lib", | ||
"//source/common/json:json_validator_lib", | ||
], | ||
) |
Oops, something went wrong.