summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/execution_service/server_implementation.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-02 16:47:13 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-04 16:05:08 +0200
commitc2f7ead468d5e65c57e7ecb49d7fbba4254c46b7 (patch)
treeb96ce2e63d9d6a2d486cb4133c290187156b97ac /src/buildtool/execution_api/execution_service/server_implementation.cpp
parent0d60cd9ba4a5c18b01b6ef996434953071f0576e (diff)
downloadjustbuild-c2f7ead468d5e65c57e7ecb49d7fbba4254c46b7.tar.gz
Replace the Auth and Auth::TLS singletons
Use a builder pattern for creation and validation, in a manner that allows also other authentication methods to be added in the future besides the current TLS/SSL. The main Auth instances are built early and then passed by not_null const pointers, to avoid passing temporaries, replacing the previous Auth::TLS instances passed by simple nullable const pointers. Where needed, these passed Auth instances are also stored, by const ref. Tests also build Auth instances as needed, either with the default 'no certification' or from the test environment arguments.
Diffstat (limited to 'src/buildtool/execution_api/execution_service/server_implementation.cpp')
-rw-r--r--src/buildtool/execution_api/execution_service/server_implementation.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/buildtool/execution_api/execution_service/server_implementation.cpp b/src/buildtool/execution_api/execution_service/server_implementation.cpp
index 4a9f23cf..676bd0a7 100644
--- a/src/buildtool/execution_api/execution_service/server_implementation.cpp
+++ b/src/buildtool/execution_api/execution_service/server_implementation.cpp
@@ -70,13 +70,15 @@ auto ServerImpl::Run(ApiBundle const& apis) -> bool {
.RegisterService(&cap)
.RegisterService(&op);
+ // check authentication credentials; currently only TLS/SSL is supported
std::shared_ptr<grpc::ServerCredentials> creds;
- if (apis.auth != nullptr) {
+ if (const auto* tls_auth = std::get_if<Auth::TLS>(&apis.auth.method);
+ tls_auth != nullptr) {
auto tls_opts = grpc::SslServerCredentialsOptions{};
- tls_opts.pem_root_certs = apis.auth->CACert();
+ tls_opts.pem_root_certs = tls_auth->ca_cert;
grpc::SslServerCredentialsOptions::PemKeyCertPair keycert = {
- apis.auth->ServerKey(), apis.auth->ServerCert()};
+ tls_auth->server_key, tls_auth->server_cert};
tls_opts.pem_key_cert_pairs.emplace_back(keycert);