-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
secret: add secret provider interface and use it for TlsCertificates (#…
…4086) Signed-off-by: Lizan Zhou <zlizan@google.com>
- Loading branch information
Showing
35 changed files
with
270 additions
and
115 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
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,28 @@ | ||
#pragma once | ||
|
||
#include "envoy/common/pure.h" | ||
#include "envoy/ssl/tls_certificate_config.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
/** | ||
* A secret provider for each kind of secret. | ||
*/ | ||
template <class SecretType> class SecretProvider { | ||
public: | ||
virtual ~SecretProvider() {} | ||
|
||
/** | ||
* @return the secret. Returns nullptr if the secret is not ready. | ||
*/ | ||
virtual const SecretType* secret() const PURE; | ||
|
||
// TODO(lizan): Add more methods for dynamic secret provider. | ||
}; | ||
|
||
typedef SecretProvider<Ssl::TlsCertificateConfig> TlsCertificateConfigProvider; | ||
typedef std::shared_ptr<TlsCertificateConfigProvider> TlsCertificateConfigProviderSharedPtr; | ||
|
||
} // 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
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,14 @@ | ||
#include "common/secret/secret_provider_impl.h" | ||
|
||
#include "common/common/assert.h" | ||
#include "common/ssl/tls_certificate_config_impl.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
TlsCertificateConfigProviderImpl::TlsCertificateConfigProviderImpl( | ||
const envoy::api::v2::auth::TlsCertificate& tls_certificate) | ||
: tls_certificate_(std::make_unique<Ssl::TlsCertificateConfigImpl>(tls_certificate)) {} | ||
|
||
} // 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,21 @@ | ||
#pragma once | ||
|
||
#include "envoy/api/v2/auth/cert.pb.h" | ||
#include "envoy/secret/secret_provider.h" | ||
#include "envoy/ssl/tls_certificate_config.h" | ||
|
||
namespace Envoy { | ||
namespace Secret { | ||
|
||
class TlsCertificateConfigProviderImpl : public TlsCertificateConfigProvider { | ||
public: | ||
TlsCertificateConfigProviderImpl(const envoy::api::v2::auth::TlsCertificate& tls_certificate); | ||
|
||
const Ssl::TlsCertificateConfig* secret() const override { return tls_certificate_.get(); } | ||
|
||
private: | ||
Ssl::TlsCertificateConfigPtr tls_certificate_; | ||
}; | ||
|
||
} // 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
Oops, something went wrong.