-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Sds api: implement SDS api #3700
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "envoy/secret/secret_callbacks.h" | ||
#include "envoy/ssl/tls_certificate_config.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
/** | ||
* An interface to fetch dynamic secret. | ||
* | ||
* TODO(JimmyCYJ): Support other types of secrets. | ||
*/ | ||
class DynamicTlsCertificateSecretProvider { | ||
public: | ||
virtual ~DynamicTlsCertificateSecretProvider() {} | ||
|
||
/** | ||
* @return the TlsCertificate secret. Returns nullptr if the secret is not found. | ||
*/ | ||
virtual const Ssl::TlsCertificateConfig* secret() const PURE; | ||
virtual void addUpdateCallback(SecretCallbacks& callback) PURE; | ||
virtual void removeUpdateCallback(SecretCallbacks& callback) PURE; | ||
}; | ||
|
||
typedef std::shared_ptr<DynamicTlsCertificateSecretProvider> | ||
DynamicTlsCertificateSecretProviderSharedPtr; | ||
|
||
} // namespace Secret | ||
} // namespace Envoy |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma once | ||
|
||
#include "envoy/api/v2/core/config_source.pb.h" | ||
#include "envoy/event/dispatcher.h" | ||
#include "envoy/local_info/local_info.h" | ||
#include "envoy/runtime/runtime.h" | ||
#include "envoy/secret/dynamic_secret_provider.h" | ||
#include "envoy/stats/stats.h" | ||
#include "envoy/upstream/cluster_manager.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
/** | ||
* DynamicTlsCertificateSecretProviderFactoryContext passed to | ||
* DynamicTlsCertificateSecretProviderFactory to access resources which are needed for creating | ||
* dynamic tls certificate secret provider. | ||
*/ | ||
class DynamicTlsCertificateSecretProviderFactoryContext { | ||
public: | ||
virtual ~DynamicTlsCertificateSecretProviderFactoryContext() {} | ||
|
||
/** | ||
* @return information about the local environment the server is running in. | ||
*/ | ||
virtual const LocalInfo::LocalInfo& local_info() PURE; | ||
|
||
/** | ||
* @return Event::Dispatcher& the main thread's dispatcher. | ||
*/ | ||
virtual Event::Dispatcher& dispatcher() PURE; | ||
|
||
/** | ||
* @return RandomGenerator& the random generator for the server. | ||
*/ | ||
virtual Runtime::RandomGenerator& random() PURE; | ||
|
||
/** | ||
* @return the server-wide stats store. | ||
*/ | ||
virtual Stats::Store& stats() PURE; | ||
|
||
/** | ||
* @return Upstream::ClusterManager. | ||
*/ | ||
virtual Upstream::ClusterManager& cluster_manager() PURE; | ||
}; | ||
|
||
/** | ||
* Factory for creating dynamic TlsCertificate secret provider. | ||
*/ | ||
class DynamicTlsCertificateSecretProviderFactory { | ||
public: | ||
virtual ~DynamicTlsCertificateSecretProviderFactory() {} | ||
|
||
/** | ||
* Finds and returns a secret provider associated to SDS config. Create a new one | ||
* if such provider does not exist. | ||
* | ||
* @param config_source a protobuf message object contains SDS config source. | ||
* @param config_name a name that uniquely refers to the SDS config source. | ||
* @return the dynamic tls certificate secret provider. | ||
*/ | ||
virtual DynamicTlsCertificateSecretProviderSharedPtr | ||
findOrCreate(const envoy::api::v2::core::ConfigSource& sds_config, | ||
std::string sds_config_name) PURE; | ||
}; | ||
|
||
} // namespace Secret | ||
} // namespace Envoy |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
#include <vector> | ||
|
||
#include "envoy/common/pure.h" | ||
#include "envoy/secret/dynamic_secret_provider.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needed? |
||
|
||
namespace Envoy { | ||
namespace Ssl { | ||
|
@@ -111,6 +112,17 @@ class ContextConfig { | |
* @return The maximum TLS protocol version to negotiate. | ||
*/ | ||
virtual unsigned maxProtocolVersion() const PURE; | ||
|
||
/** | ||
* @return true if the config is valid. Only when SDS dynamic secret is needed, but has not been | ||
* downloaded yet, the config is invalid. | ||
*/ | ||
virtual bool isValid() const PURE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
|
||
/** | ||
* @return the DynamicSecretProvider object. | ||
*/ | ||
virtual Secret::DynamicTlsCertificateSecretProvider* getDynamicSecretProvider() const PURE; | ||
}; | ||
|
||
class ClientContextConfig : public virtual ContextConfig { | ||
|
@@ -127,6 +139,8 @@ class ClientContextConfig : public virtual ContextConfig { | |
virtual bool allowRenegotiation() const PURE; | ||
}; | ||
|
||
typedef std::unique_ptr<ClientContextConfig> ClientContextConfigPtr; | ||
|
||
class ServerContextConfig : public virtual ContextConfig { | ||
public: | ||
struct SessionTicketKey { | ||
|
@@ -148,5 +162,7 @@ class ServerContextConfig : public virtual ContextConfig { | |
virtual const std::vector<SessionTicketKey>& sessionTicketKeys() const PURE; | ||
}; | ||
|
||
typedef std::unique_ptr<ServerContextConfig> ServerContextConfigPtr; | ||
|
||
} // namespace Ssl | ||
} // namespace Envoy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think this is used.