diff --git a/CMakeLists.txt b/CMakeLists.txt index 039800c612c1f2cee71fa65bf4551bd25ff7f36c..26de3c71e4f8eede01368fa4913c2c02ced2d169 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,8 @@ if(NOT clang_tidy) message(STATUS "clang-tidy: Not found") else() message(STATUS "clang-tidy: ${clang_tidy}") - set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}" "--header-filter=connection.h" + set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}" + "--header-filter=caosdb/.*[^\(\.pb\.h\)]$" "--checks=*,-fuchsia-*,-llvm-include-order,-llvmlibc-*" "--warnings-as-errors=*") endif() @@ -68,12 +69,12 @@ set_target_properties(caosdb PROPERTIES CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY}" CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}" ) -add_executable(caosdbcli src/caosdbcli.cpp) -set_target_properties(caosdbcli PROPERTIES - CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY}" - CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}" - ) -target_link_libraries(caosdbcli caosdb ${CONAN_LIBS}) +#add_executable(caosdbcli src/caosdbcli.cpp) +#set_target_properties(caosdbcli PROPERTIES + #CXX_CLANG_TIDY "${_CMAKE_CXX_CLANG_TIDY}" + #CXX_INCLUDE_WHAT_YOU_USE "${_CMAKE_CXX_INCLUDE_WHAT_YOU_USE}" + #) +#target_link_libraries(caosdbcli caosdb caosdb_info_v1alpha1 ${CONAN_LIBS}) if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") # supress warnings during build of gtest diff --git a/include/caosdb/authentication.h b/include/caosdb/authentication.h index a1fdca8c08c92fcd0dff637725851e67b66b7696..de3f9848141c504a936b51e43f5f9b919c2c869e 100644 --- a/include/caosdb/authentication.h +++ b/include/caosdb/authentication.h @@ -27,12 +27,15 @@ * @date 2021-06-28 * @brief Configuration and setup of the client authentication. */ -#include <string> -#include <iosfwd> -#include <memory> -#include <grpc/grpc.h> -#include <grpcpp/security/credentials.h> -#include "caosdb/utils.h" + +#include <grpcpp/security/credentials.h> // for MetadataCredentialsPlugin +#include <map> // for multimap +#include <memory> // for shared_ptr +#include <string> // for string +#include "caosdb/utils.h" // for base64_encode +#include "grpcpp/impl/codegen/status.h" // for Status +#include "grpcpp/impl/codegen/string_ref.h" // for string_ref +namespace grpc { class AuthContext; } namespace caosdb { namespace authentication { @@ -47,7 +50,7 @@ using grpc::string_ref; */ class Authenticator { public: - virtual auto getCallCredentials() const + [[nodiscard]] virtual auto getCallCredentials() const -> std::shared_ptr<grpc::CallCredentials> = 0; }; @@ -64,10 +67,10 @@ private: public: MetadataCredentialsPluginImpl(std::string key, std::string value); - Status + auto GetMetadata(string_ref service_url, string_ref method_name, const AuthContext &channel_auth_context, - std::multimap<grpc::string, grpc::string> *metadata) override; + std::multimap<grpc::string, grpc::string> *metadata) -> Status override; }; class PlainPasswordAuthenticator : public Authenticator { @@ -78,7 +81,7 @@ public: PlainPasswordAuthenticator(const std::string &username, const std::string &password); - auto getCallCredentials() const + [[nodiscard]] auto getCallCredentials() const -> std::shared_ptr<grpc::CallCredentials> override; }; } // namespace authentication diff --git a/include/caosdb/connection.h b/include/caosdb/connection.h index 978fdcc6394fe311d202bfc91938330223635c0c..c233dce61c550a8b6e20e029456dc00b73b754b7 100644 --- a/include/caosdb/connection.h +++ b/include/caosdb/connection.h @@ -27,26 +27,13 @@ * @date 2021-05-18 * @brief Configuration and setup of the connection. */ -#include <string> -#include <iosfwd> -#include "caosdb/authentication.h" -#include <memory> -#include <grpc/grpc.h> -#include <grpcpp/channel.h> -#include <grpcpp/client_context.h> -#include <grpcpp/create_channel.h> -#include <grpcpp/security/credentials.h> -#include "caosdb/info/v1alpha1/main.grpc.pb.h" -namespace grpc { -class ChannelCredentials; -} // namespace grpc -namespace caosdb { -namespace info { -namespace v1alpha1 { -class VersionInfo; -} // namespace v1alpha1 -} // namespace info -} // namespace caosdb +#include <iosfwd> // for ostream +#include <memory> // for shared_ptr, unique_ptr +#include <string> // for string +#include "caosdb/info/v1alpha1/main.grpc.pb.h" // for GeneralInfoService +namespace caosdb { namespace authentication { class Authenticator; } } +namespace caosdb { namespace info { namespace v1alpha1 { class VersionInfo; } } } +namespace grpc { class ChannelCredentials; } namespace caosdb::connection { using caosdb::authentication::Authenticator; diff --git a/include/caosdb/utils.h b/include/caosdb/utils.h index 79393b12cca134e00c1e874735c6cba886a31deb..e00c1806344493c10142c0e2a3939fcbfe47662b 100644 --- a/include/caosdb/utils.h +++ b/include/caosdb/utils.h @@ -52,14 +52,14 @@ inline auto load_string_file(const std::string &path) -> std::string { * fall_back value. */ inline auto get_env_var(const std::string &key, const std::string &fall_back) - -> const std::string { + -> std::string { const char *val = getenv(key.c_str()); if (val == nullptr) { return fall_back; - } else { - const auto result = std::string(val); - return result; } + + auto result = std::string(val); + return result; } /** diff --git a/src/caosdb/authentication.cpp b/src/caosdb/authentication.cpp index 5e6a89a08358794edea8f2610ada9ac594bb760c..4ff218538671ee726d0869749b62e05bb99c16c7 100644 --- a/src/caosdb/authentication.cpp +++ b/src/caosdb/authentication.cpp @@ -18,13 +18,14 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ -#include <string> -#include <memory> #include "caosdb/authentication.h" -#include <grpcpp/impl/codegen/status.h> -#include <grpcpp/impl/codegen/string_ref.h> -#include <map> -#include <utility> +#include <grpcpp/impl/codegen/status.h> // for Status, Status::OK +#include <grpcpp/impl/codegen/string_ref.h> // for string_ref +#include <map> // for multimap +#include <memory> // for allocator, shared_ptr +#include <string> // for basic_string, operator+ +#include <utility> // for pair, move, make_pair +#include "grpcpp/security/credentials.h" // for MetadataCredentialsFromP... namespace caosdb::authentication { using caosdb::utils::base64_encode; diff --git a/src/caosdb/connection.cpp b/src/caosdb/connection.cpp index 635c8bd5f2ca472b32c67f2323eee296cbdb976a..f7fe59245d2c121d1013f008b768c9e69d1cb487 100644 --- a/src/caosdb/connection.cpp +++ b/src/caosdb/connection.cpp @@ -19,20 +19,21 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. * */ - -#include <grpcpp/create_channel.h> -#include <grpcpp/impl/codegen/client_context.h> -#include <grpcpp/impl/codegen/status.h> -#include <grpcpp/security/credentials.h> -#include <iostream> -#include <stdexcept> -#include <string> -#include "caosdb/info/v1alpha1/main.grpc.pb.h" -#include "caosdb/info/v1alpha1/main.pb.h" -#include "caosdb/exceptions.h" #include "caosdb/connection.h" -#include "caosdb/utils.h" -#include "caosdb/authentication.h" +#include <grpcpp/create_channel.h> // for CreateChannel +#include <grpcpp/impl/codegen/client_context.h> // for ClientContext +#include <grpcpp/impl/codegen/status.h> // for Status +#include <grpcpp/security/credentials.h> // for SslCredentials +#include <iostream> // for operator<<, basic_... +#include <stdexcept> // for runtime_error +#include <string> // for operator+, char_tr... +#include "caosdb/authentication.h" // for Authenticator +#include "caosdb/exceptions.h" // for AuthenticationError +#include "caosdb/info/v1alpha1/main.grpc.pb.h" // for GeneralInfoService +#include "caosdb/info/v1alpha1/main.pb.h" // for GetVersionInfoResp... +#include "caosdb/utils.h" // for load_string_file +#include "grpcpp/impl/codegen/status_code_enum.h" // for StatusCode, UNAUTH... +namespace grpc { class Channel; } namespace caosdb::connection { using caosdb::authentication::Authenticator;