From 2fc4cfadcf878b403f44bb81007d2c8eb0114548 Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 23 Jul 2020 16:18:23 -0700 Subject: [PATCH] Move ServerCredentials from ::grpc_impl to ::grpc Reverts: https://github.com/grpc/grpc/pull/18452 --- BUILD | 1 - BUILD.gn | 1 - CMakeLists.txt | 2 - Makefile | 2 - build_autogenerated.yaml | 2 - gRPC-C++.podspec | 1 - .../grpcpp/impl/codegen/server_interface.h | 4 +- include/grpcpp/security/server_credentials.h | 90 +++++++++---------- .../grpcpp/security/server_credentials_impl.h | 89 ------------------ include/grpcpp/server_builder.h | 8 +- .../external_connection_acceptor_impl.h | 1 - src/cpp/server/insecure_server_credentials.cc | 4 +- src/cpp/server/secure_server_credentials.cc | 6 +- src/cpp/server/secure_server_credentials.h | 13 +-- src/cpp/server/server_credentials.cc | 6 +- tools/doxygen/Doxyfile.c++ | 1 - tools/doxygen/Doxyfile.c++.internal | 1 - 17 files changed, 58 insertions(+), 174 deletions(-) delete mode 100644 include/grpcpp/security/server_credentials_impl.h diff --git a/BUILD b/BUILD index 036c782ac30..0635f9e21b5 100644 --- a/BUILD +++ b/BUILD @@ -253,7 +253,6 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/security/credentials.h", "include/grpcpp/security/credentials_impl.h", "include/grpcpp/security/server_credentials.h", - "include/grpcpp/security/server_credentials_impl.h", "include/grpcpp/security/tls_credentials_options.h", "include/grpcpp/server.h", "include/grpcpp/server_impl.h", diff --git a/BUILD.gn b/BUILD.gn index 59835609c50..e645069d933 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1179,7 +1179,6 @@ config("grpc_config") { "include/grpcpp/security/credentials.h", "include/grpcpp/security/credentials_impl.h", "include/grpcpp/security/server_credentials.h", - "include/grpcpp/security/server_credentials_impl.h", "include/grpcpp/security/tls_credentials_options.h", "include/grpcpp/server.h", "include/grpcpp/server_builder.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b85e61f25a..342237b4b3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2821,7 +2821,6 @@ foreach(_hdr include/grpcpp/security/credentials.h include/grpcpp/security/credentials_impl.h include/grpcpp/security/server_credentials.h - include/grpcpp/security/server_credentials_impl.h include/grpcpp/security/tls_credentials_options.h include/grpcpp/server.h include/grpcpp/server_builder.h @@ -3515,7 +3514,6 @@ foreach(_hdr include/grpcpp/security/credentials.h include/grpcpp/security/credentials_impl.h include/grpcpp/security/server_credentials.h - include/grpcpp/security/server_credentials_impl.h include/grpcpp/security/tls_credentials_options.h include/grpcpp/server.h include/grpcpp/server_builder.h diff --git a/Makefile b/Makefile index 40e2642512c..42625b211cc 100644 --- a/Makefile +++ b/Makefile @@ -4971,7 +4971,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/security/credentials.h \ include/grpcpp/security/credentials_impl.h \ include/grpcpp/security/server_credentials.h \ - include/grpcpp/security/server_credentials_impl.h \ include/grpcpp/security/tls_credentials_options.h \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ @@ -5663,7 +5662,6 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/security/credentials.h \ include/grpcpp/security/credentials_impl.h \ include/grpcpp/security/server_credentials.h \ - include/grpcpp/security/server_credentials_impl.h \ include/grpcpp/security/tls_credentials_options.h \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 0737db79647..38a4054cce5 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -2154,7 +2154,6 @@ libs: - include/grpcpp/security/credentials.h - include/grpcpp/security/credentials_impl.h - include/grpcpp/security/server_credentials.h - - include/grpcpp/security/server_credentials_impl.h - include/grpcpp/security/tls_credentials_options.h - include/grpcpp/server.h - include/grpcpp/server_builder.h @@ -2540,7 +2539,6 @@ libs: - include/grpcpp/security/credentials.h - include/grpcpp/security/credentials_impl.h - include/grpcpp/security/server_credentials.h - - include/grpcpp/security/server_credentials_impl.h - include/grpcpp/security/tls_credentials_options.h - include/grpcpp/server.h - include/grpcpp/server_builder.h diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index c1f21867f5e..ef8e8acff85 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -166,7 +166,6 @@ Pod::Spec.new do |s| 'include/grpcpp/security/credentials.h', 'include/grpcpp/security/credentials_impl.h', 'include/grpcpp/security/server_credentials.h', - 'include/grpcpp/security/server_credentials_impl.h', 'include/grpcpp/security/tls_credentials_options.h', 'include/grpcpp/server.h', 'include/grpcpp/server_builder.h', diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index 3294c4037b5..0c556f0a5f0 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -36,12 +36,12 @@ namespace grpc_impl { class Channel; class CompletionQueue; class ServerCompletionQueue; -class ServerCredentials; } // namespace grpc_impl namespace grpc { class AsyncGenericService; class GenericServerContext; +class ServerCredentials; class Service; extern CoreCodegenInterface* g_core_codegen_interface; @@ -173,7 +173,7 @@ class ServerInterface : public internal::CallHook { /// /// \warning It's an error to call this method on an already started server. virtual int AddListeningPort(const std::string& addr, - grpc_impl::ServerCredentials* creds) = 0; + ServerCredentials* creds) = 0; /// Start the server. /// diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h index 5228ac138cc..d8de6b658b4 100644 --- a/include/grpcpp/security/server_credentials.h +++ b/include/grpcpp/security/server_credentials.h @@ -1,6 +1,6 @@ /* * - * Copyright 2019 gRPC authors. + * Copyright 2015 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,71 +19,69 @@ #ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_H #define GRPCPP_SECURITY_SERVER_CREDENTIALS_H -#include +#include +#include + +#include +#include +#include +#include + +struct grpc_server; namespace grpc_impl { class Server; } // namespace grpc_impl namespace grpc { +struct SslServerCredentialsOptions; -typedef ::grpc_impl::ServerCredentials ServerCredentials; +/// Wrapper around \a grpc_server_credentials, a way to authenticate a server. +class ServerCredentials { + public: + virtual ~ServerCredentials(); -/// Options to create ServerCredentials with SSL -struct SslServerCredentialsOptions { - /// \warning Deprecated - SslServerCredentialsOptions() - : force_client_auth(false), - client_certificate_request(GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE) {} - SslServerCredentialsOptions( - grpc_ssl_client_certificate_request_type request_type) - : force_client_auth(false), client_certificate_request(request_type) {} + /// This method is not thread-safe and has to be called before the server is + /// started. The last call to this function wins. + virtual void SetAuthMetadataProcessor( + const std::shared_ptr& processor) = 0; - struct PemKeyCertPair { - std::string private_key; - std::string cert_chain; - }; - std::string pem_root_certs; - std::vector pem_key_cert_pairs; - /// \warning Deprecated - bool force_client_auth; + private: + friend class ::grpc_impl::Server; - /// If both \a force_client_auth and \a client_certificate_request - /// fields are set, \a force_client_auth takes effect, i.e. - /// \a REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY - /// will be enforced. - grpc_ssl_client_certificate_request_type client_certificate_request; + /// Tries to bind \a server to the given \a addr (eg, localhost:1234, + /// 192.168.1.1:31416, [::1]:27182, etc.) + /// + /// \return bound port number on success, 0 on failure. + // TODO(dgq): the "port" part seems to be a misnomer. + virtual int AddPortToServer(const std::string& addr, grpc_server* server) = 0; }; -static inline std::shared_ptr SslServerCredentials( - const SslServerCredentialsOptions& options) { - return ::grpc_impl::SslServerCredentials(options); -} +/// Builds SSL ServerCredentials given SSL specific options +std::shared_ptr SslServerCredentials( + const grpc::SslServerCredentialsOptions& options); -static inline std::shared_ptr InsecureServerCredentials() { - return ::grpc_impl::InsecureServerCredentials(); -} +/// Builds insecure server credentials. +std::shared_ptr InsecureServerCredentials(); namespace experimental { -typedef ::grpc_impl::experimental::AltsServerCredentialsOptions - AltsServerCredentialsOptions; +/// Options to create ServerCredentials with ALTS +struct AltsServerCredentialsOptions { + /// Add fields if needed. +}; -static inline std::shared_ptr AltsServerCredentials( - const AltsServerCredentialsOptions& options) { - return ::grpc_impl::experimental::AltsServerCredentials(options); -} +/// Builds ALTS ServerCredentials given ALTS specific options +std::shared_ptr AltsServerCredentials( + const AltsServerCredentialsOptions& options); -static inline std::shared_ptr LocalServerCredentials( - grpc_local_connect_type type) { - return ::grpc_impl::experimental::LocalServerCredentials(type); -} +/// Builds Local ServerCredentials. +std::shared_ptr LocalServerCredentials( + grpc_local_connect_type type); /// Builds TLS ServerCredentials given TLS options. -static inline std::shared_ptr TlsServerCredentials( - const ::grpc_impl::experimental::TlsCredentialsOptions& options) { - return ::grpc_impl::experimental::TlsServerCredentials(options); -} +std::shared_ptr TlsServerCredentials( + const TlsCredentialsOptions& options); } // namespace experimental } // namespace grpc diff --git a/include/grpcpp/security/server_credentials_impl.h b/include/grpcpp/security/server_credentials_impl.h deleted file mode 100644 index 7e9e784f6e5..00000000000 --- a/include/grpcpp/security/server_credentials_impl.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H -#define GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H - -#include -#include - -#include -#include -#include -#include - -struct grpc_server; - -namespace grpc { - -struct SslServerCredentialsOptions; -} // namespace grpc -namespace grpc_impl { -class Server; - -/// Wrapper around \a grpc_server_credentials, a way to authenticate a server. -class ServerCredentials { - public: - virtual ~ServerCredentials(); - - /// This method is not thread-safe and has to be called before the server is - /// started. The last call to this function wins. - virtual void SetAuthMetadataProcessor( - const std::shared_ptr& processor) = 0; - - private: - friend class ::grpc_impl::Server; - - /// Tries to bind \a server to the given \a addr (eg, localhost:1234, - /// 192.168.1.1:31416, [::1]:27182, etc.) - /// - /// \return bound port number on success, 0 on failure. - // TODO(dgq): the "port" part seems to be a misnomer. - virtual int AddPortToServer(const std::string& addr, grpc_server* server) = 0; -}; - -/// Builds SSL ServerCredentials given SSL specific options -std::shared_ptr SslServerCredentials( - const grpc::SslServerCredentialsOptions& options); - -/// Builds insecure server credentials. -std::shared_ptr InsecureServerCredentials(); - -namespace experimental { - -/// Options to create ServerCredentials with ALTS -struct AltsServerCredentialsOptions { - /// Add fields if needed. -}; - -/// Builds ALTS ServerCredentials given ALTS specific options -std::shared_ptr AltsServerCredentials( - const AltsServerCredentialsOptions& options); - -/// Builds Local ServerCredentials. -std::shared_ptr LocalServerCredentials( - grpc_local_connect_type type); - -/// Builds TLS ServerCredentials given TLS options. -std::shared_ptr TlsServerCredentials( - const TlsCredentialsOptions& options); - -} // namespace experimental -} // namespace grpc_impl - -#endif // GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H diff --git a/include/grpcpp/server_builder.h b/include/grpcpp/server_builder.h index 2ebf6c2716f..8a15abad3fb 100644 --- a/include/grpcpp/server_builder.h +++ b/include/grpcpp/server_builder.h @@ -43,12 +43,12 @@ namespace grpc_impl { class CompletionQueue; class Server; class ServerCompletionQueue; -class ServerCredentials; } // namespace grpc_impl namespace grpc { class AsyncGenericService; +class ServerCredentials; class Service; namespace testing { class ServerBuilderPluginTest; @@ -130,7 +130,7 @@ class ServerBuilder { /// does not modify this pointer. ServerBuilder& AddListeningPort( const std::string& addr_uri, - std::shared_ptr creds, + std::shared_ptr creds, int* selected_port = nullptr); /// Add a completion queue for handling asynchronous services. @@ -312,7 +312,7 @@ class ServerBuilder { /// Experimental, to be deprecated struct Port { std::string addr; - std::shared_ptr creds; + std::shared_ptr creds; int* selected_port; }; @@ -380,7 +380,7 @@ class ServerBuilder { /// List of completion queues added via \a AddCompletionQueue method. std::vector cqs_; - std::shared_ptr creds_; + std::shared_ptr creds_; std::vector> plugins_; grpc_resource_quota* resource_quota_; grpc::AsyncGenericService* generic_service_{nullptr}; diff --git a/src/cpp/server/external_connection_acceptor_impl.h b/src/cpp/server/external_connection_acceptor_impl.h index 3fb94c90848..9c65ac1660d 100644 --- a/src/cpp/server/external_connection_acceptor_impl.h +++ b/src/cpp/server/external_connection_acceptor_impl.h @@ -23,7 +23,6 @@ #include #include -#include #include #include diff --git a/src/cpp/server/insecure_server_credentials.cc b/src/cpp/server/insecure_server_credentials.cc index bc908920b8d..04e5435efb9 100644 --- a/src/cpp/server/insecure_server_credentials.cc +++ b/src/cpp/server/insecure_server_credentials.cc @@ -21,7 +21,7 @@ #include #include -namespace grpc_impl { +namespace grpc { namespace { class InsecureServerCredentialsImpl final : public ServerCredentials { public: @@ -41,4 +41,4 @@ std::shared_ptr InsecureServerCredentials() { new InsecureServerCredentialsImpl()); } -} // namespace grpc_impl +} // namespace grpc diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc index f94696fd767..6ca31ee0843 100644 --- a/src/cpp/server/secure_server_credentials.cc +++ b/src/cpp/server/secure_server_credentials.cc @@ -92,10 +92,6 @@ void AuthMetadataProcessorAyncWrapper::InvokeProcessor( status.error_message().c_str()); } -} // namespace grpc - -namespace grpc_impl { - int SecureServerCredentials::AddPortToServer(const std::string& addr, grpc_server* server) { return grpc_server_add_secure_http2_port(server, addr.c_str(), creds_); @@ -156,4 +152,4 @@ std::shared_ptr TlsServerCredentials( } } // namespace experimental -} // namespace grpc_impl +} // namespace grpc diff --git a/src/cpp/server/secure_server_credentials.h b/src/cpp/server/secure_server_credentials.h index 9e9e33579f0..407d70766b5 100644 --- a/src/cpp/server/secure_server_credentials.h +++ b/src/cpp/server/secure_server_credentials.h @@ -28,14 +28,9 @@ #include "src/cpp/server/thread_pool_interface.h" -namespace grpc_impl { - -class SecureServerCredentials; -} // namespace grpc_impl - namespace grpc { -typedef ::grpc_impl::SecureServerCredentials SecureServerCredentials; +class SecureServerCredentials; class AuthMetadataProcessorAyncWrapper final { public: @@ -61,10 +56,6 @@ class AuthMetadataProcessorAyncWrapper final { std::shared_ptr processor_; }; -} // namespace grpc - -namespace grpc_impl { - class SecureServerCredentials final : public ServerCredentials { public: explicit SecureServerCredentials(grpc_server_credentials* creds) @@ -83,6 +74,6 @@ class SecureServerCredentials final : public ServerCredentials { std::unique_ptr processor_; }; -} // namespace grpc_impl +} // namespace grpc #endif // GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H diff --git a/src/cpp/server/server_credentials.cc b/src/cpp/server/server_credentials.cc index 8b85264f9d7..c3b3a8b3793 100644 --- a/src/cpp/server/server_credentials.cc +++ b/src/cpp/server/server_credentials.cc @@ -16,10 +16,10 @@ * */ -#include +#include -namespace grpc_impl { +namespace grpc { ServerCredentials::~ServerCredentials() {} -} // namespace grpc_impl +} // namespace grpc diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 3ce6109b49d..ac34b49e30b 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -1026,7 +1026,6 @@ include/grpcpp/security/auth_metadata_processor.h \ include/grpcpp/security/credentials.h \ include/grpcpp/security/credentials_impl.h \ include/grpcpp/security/server_credentials.h \ -include/grpcpp/security/server_credentials_impl.h \ include/grpcpp/security/tls_credentials_options.h \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 2dd2cb0c123..5be2623a948 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1026,7 +1026,6 @@ include/grpcpp/security/auth_metadata_processor.h \ include/grpcpp/security/credentials.h \ include/grpcpp/security/credentials_impl.h \ include/grpcpp/security/server_credentials.h \ -include/grpcpp/security/server_credentials_impl.h \ include/grpcpp/security/tls_credentials_options.h \ include/grpcpp/server.h \ include/grpcpp/server_builder.h \