-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: clusters and listeners read static secrets from Bootstrap.static_resources #3465
Merged
mattklein123
merged 5 commits into
envoyproxy:master
from
mangchiandjjoe:sds_static_secret_integration
Jun 18, 2018
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c8fe612
clusters and listeners read static secrets from Bootstrap.static_reso…
mangchiandjjoe 8194b5b
Added secretManager() to ClusterManagerFactory interface
mangchiandjjoe 3ebeff4
Removed unnecessary changes
mangchiandjjoe 4753fe0
Changed the location of secret_manager argument
mangchiandjjoe 0b730b1
Changed the location of secret_manager argument
mangchiandjjoe 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
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,18 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "secret_manager_interface", | ||
hdrs = ["secret_manager.h"], | ||
deps = [ | ||
"//include/envoy/ssl:tls_certificate_config_interface", | ||
"@envoy_api//envoy/api/v2/auth:cert_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,34 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include "envoy/api/v2/auth/cert.pb.h" | ||
#include "envoy/ssl/tls_certificate_config.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
/** | ||
* A manager for static secrets. | ||
* | ||
* TODO(jaebong) Support dynamic secrets. | ||
*/ | ||
class SecretManager { | ||
public: | ||
virtual ~SecretManager() {} | ||
|
||
/** | ||
* @param secret a protobuf message of envoy::api::v2::auth::Secret. | ||
* @throw an EnvoyException if the secret is invalid or not supported. | ||
*/ | ||
virtual void addOrUpdateSecret(const envoy::api::v2::auth::Secret& secret) PURE; | ||
|
||
/** | ||
* @param name a name of the Ssl::TlsCertificateConfig. | ||
* @return the TlsCertificate secret. Returns nullptr if the secret is not found. | ||
*/ | ||
virtual const Ssl::TlsCertificateConfig* findTlsCertificate(const std::string& name) 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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
#include <string> | ||
|
||
#include "envoy/network/transport_socket.h" | ||
#include "envoy/secret/secret_manager.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. not needed 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. Removed |
||
#include "envoy/ssl/context_manager.h" | ||
|
||
#include "common/protobuf/protobuf.h" | ||
|
@@ -19,14 +20,19 @@ class TransportSocketFactoryContext { | |
virtual ~TransportSocketFactoryContext() {} | ||
|
||
/** | ||
* @return Ssl::ContextManager& the SSL context manager | ||
* @return Ssl::ContextManager& the SSL context manager. | ||
*/ | ||
virtual Ssl::ContextManager& sslContextManager() PURE; | ||
|
||
/** | ||
* @return Stats::Scope& the transport socket's stats scope. | ||
*/ | ||
virtual Stats::Scope& statsScope() const PURE; | ||
|
||
/** | ||
* Return the instance of secret manager. | ||
*/ | ||
virtual Secret::SecretManager& secretManager() PURE; | ||
}; | ||
|
||
class TransportSocketConfigFactory { | ||
|
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,29 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "envoy/common/pure.h" | ||
|
||
namespace Envoy { | ||
namespace Ssl { | ||
|
||
class TlsCertificateConfig { | ||
public: | ||
virtual ~TlsCertificateConfig() {} | ||
|
||
/** | ||
* @return a string of certificate chain | ||
*/ | ||
virtual const std::string& certificateChain() const PURE; | ||
|
||
/** | ||
* @return a string of private key | ||
*/ | ||
virtual const std::string& privateKey() const PURE; | ||
}; | ||
|
||
typedef std::unique_ptr<TlsCertificateConfig> TlsCertificateConfigPtr; | ||
|
||
} // namespace Ssl | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "secret_manager_impl_lib", | ||
srcs = ["secret_manager_impl.cc"], | ||
hdrs = ["secret_manager_impl.h"], | ||
deps = [ | ||
"//include/envoy/secret:secret_manager_interface", | ||
"//source/common/common:minimal_logger_lib", | ||
"//source/common/ssl:tls_certificate_config_impl_lib", | ||
"@envoy_api//envoy/api/v2/auth:cert_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,28 @@ | ||
#include "common/secret/secret_manager_impl.h" | ||
|
||
#include "envoy/common/exception.h" | ||
|
||
#include "common/ssl/tls_certificate_config_impl.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
void SecretManagerImpl::addOrUpdateSecret(const envoy::api::v2::auth::Secret& secret) { | ||
switch (secret.type_case()) { | ||
case envoy::api::v2::auth::Secret::TypeCase::kTlsCertificate: | ||
tls_certificate_secrets_[secret.name()] = | ||
std::make_unique<Ssl::TlsCertificateConfigImpl>(secret.tls_certificate()); | ||
break; | ||
default: | ||
throw EnvoyException("Secret type not implemented"); | ||
} | ||
} | ||
|
||
const Ssl::TlsCertificateConfig* | ||
SecretManagerImpl::findTlsCertificate(const std::string& name) const { | ||
auto secret = tls_certificate_secrets_.find(name); | ||
return (secret != tls_certificate_secrets_.end()) ? secret->second.get() : nullptr; | ||
} | ||
|
||
} // 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,23 @@ | ||
#pragma once | ||
|
||
#include <unordered_map> | ||
|
||
#include "envoy/secret/secret_manager.h" | ||
#include "envoy/ssl/tls_certificate_config.h" | ||
|
||
#include "common/common/logger.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
class SecretManagerImpl : public SecretManager, Logger::Loggable<Logger::Id::upstream> { | ||
public: | ||
void addOrUpdateSecret(const envoy::api::v2::auth::Secret& secret) override; | ||
const Ssl::TlsCertificateConfig* findTlsCertificate(const std::string& name) const override; | ||
|
||
private: | ||
std::unordered_map<std::string, Ssl::TlsCertificateConfigPtr> tls_certificate_secrets_; | ||
}; | ||
|
||
} // 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
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.
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: This isn't needed anymore.
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.
Removed
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.
secret_manager_interface is required here again.