From 67565b767de660e4d6dcb623db86b7235386746b Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Mon, 24 Feb 2020 21:33:48 -0800 Subject: [PATCH 1/6] CallCredentials debug string API --- BUILD | 1 + BUILD.gn | 1 + CMakeLists.txt | 18 ++- Makefile | 55 +++++--- build.yaml | 4 +- build_config.rb | 2 +- config.m4 | 17 +++ config.w32 | 19 +++ gRPC-C++.podspec | 1 + gRPC-Core.podspec | 1 + grpc.gemspec | 31 +++++ grpc.gyp | 1 + include/grpc/grpc_security.h | 5 + include/grpcpp/security/credentials_impl.h | 5 + package.xml | 31 +++++ .../composite/composite_credentials.cc | 16 +++ .../composite/composite_credentials.h | 3 + .../lib/security/credentials/credentials.h | 4 + .../credentials/fake/fake_credentials.h | 6 + .../credentials/iam/iam_credentials.cc | 9 +- .../credentials/iam/iam_credentials.h | 4 + .../credentials/jwt/jwt_credentials.cc | 1 - .../credentials/jwt/jwt_credentials.h | 12 ++ .../credentials/oauth2/oauth2_credentials.cc | 31 ++++- .../credentials/oauth2/oauth2_credentials.h | 9 ++ .../credentials/plugin/plugin_credentials.cc | 10 ++ .../credentials/plugin/plugin_credentials.h | 2 + src/core/lib/surface/version.cc | 2 +- src/cpp/client/secure_credentials.cc | 11 ++ src/cpp/client/secure_credentials.h | 5 + src/objective-c/tests/version.h | 2 +- src/python/grpcio/grpc_core_dependencies.py | 15 +++ test/core/security/credentials_test.cc | 102 ++++++++++++++- test/cpp/end2end/end2end_test.cc | 121 +++++++++++++++--- tools/doxygen/Doxyfile.core | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- 36 files changed, 507 insertions(+), 54 deletions(-) diff --git a/BUILD b/BUILD index 19d4c81f554..f646c2a655c 100644 --- a/BUILD +++ b/BUILD @@ -559,6 +559,7 @@ grpc_cc_library( "absl/memory", "absl/strings", "absl/strings:str_format", + "absl/time:time", ], language = "c++", public_hdrs = GPR_PUBLIC_HDRS, diff --git a/BUILD.gn b/BUILD.gn index f821a9e1cdc..122c579bd5b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -166,6 +166,7 @@ config("grpc_config") { ":absl/strings:str_format", ":absl/strings:strings", ":absl/types:optional", + ":absl/time:time", ] public_configs = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index a01abb00b85..5535b943c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,8 +26,8 @@ cmake_minimum_required(VERSION 3.5.1) set(PACKAGE_NAME "grpc") set(PACKAGE_VERSION "1.28.0-dev") -set(gRPC_CORE_VERSION "9.0.0") -set(gRPC_CORE_SOVERSION "9") +set(gRPC_CORE_VERSION "10.0.0") +set(gRPC_CORE_SOVERSION "10") set(gRPC_CPP_VERSION "1.28.0-dev") set(gRPC_CPP_SOVERSION "1") set(gRPC_CSHARP_VERSION "2.28.0-dev") @@ -105,6 +105,7 @@ set(gRPC_ABSL_USED_TARGETS absl_base absl_base_internal absl_bits + absl_civil_time absl_compressed_tuple absl_config absl_core_headers @@ -124,6 +125,8 @@ set(gRPC_ABSL_USED_TARGETS absl_strings absl_strings_internal absl_throw_delegate + absl_time + absl_time_zone absl_type_traits absl_utility absl_meta @@ -1445,6 +1448,7 @@ target_link_libraries(gpr absl::str_format absl::strings absl::optional + absl::time ) if(_gRPC_PLATFORM_ANDROID) target_link_libraries(gpr @@ -18575,7 +18579,7 @@ generate_pkgconfig( "gRPC platform support library" "${gRPC_CORE_VERSION}" "" - "-lgpr -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgpr -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "gpr.pc") @@ -18585,7 +18589,7 @@ generate_pkgconfig( "high performance general RPC framework" "${gRPC_CORE_VERSION}" "gpr openssl" - "-lgrpc -laddress_sorting -lupb -lcares -lz -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc -laddress_sorting -lupb -lcares -lz -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc.pc") @@ -18595,7 +18599,7 @@ generate_pkgconfig( "high performance general RPC framework without SSL" "${gRPC_CORE_VERSION}" "gpr" - "-lgrpc_unsecure -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc_unsecure -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc_unsecure.pc") @@ -18605,7 +18609,7 @@ generate_pkgconfig( "C++ wrapper for gRPC" "${PACKAGE_VERSION}" "grpc" - "-lgrpc++ -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc++ -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc++.pc") @@ -18615,6 +18619,6 @@ generate_pkgconfig( "C++ wrapper for gRPC without SSL" "${PACKAGE_VERSION}" "grpc_unsecure" - "-lgrpc++_unsecure -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc++_unsecure -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc++_unsecure.pc") diff --git a/Makefile b/Makefile index 25481e07ce6..79a05177383 100644 --- a/Makefile +++ b/Makefile @@ -469,7 +469,7 @@ E = @echo Q = @ endif -CORE_VERSION = 9.0.0 +CORE_VERSION = 10.0.0 CPP_VERSION = 1.28.0-dev CSHARP_VERSION = 2.28.0-dev @@ -519,7 +519,7 @@ SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_EXT_CSHARP = dll SHARED_PREFIX = -SHARED_VERSION_CORE = -9 +SHARED_VERSION_CORE = -10 SHARED_VERSION_CPP = -1 SHARED_VERSION_CSHARP = -2 else ifeq ($(SYSTEM),Darwin) @@ -3266,7 +3266,7 @@ install-shared_c: shared_c strip-shared_c install-pkg-config_c ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libaddress_sorting.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libaddress_sorting.so.9 + $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libaddress_sorting.so.10 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libaddress_sorting.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3275,7 +3275,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgpr.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.9 + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.10 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3284,7 +3284,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.9 + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.10 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3293,7 +3293,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_cronet.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.9 + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.10 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3302,7 +3302,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_unsecure.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.9 + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.10 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -3311,7 +3311,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libupb.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libupb.so.9 + $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libupb.so.10 $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libupb.so endif ifneq ($(SYSTEM),MINGW32) @@ -3481,8 +3481,8 @@ $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.9 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.9 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libaddress_sorting.so.10 -o $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBADDRESS_SORTING_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so.10 $(Q) ln -sf $(SHARED_PREFIX)address_sorting$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libaddress_sorting$(SHARED_VERSION_CORE).so endif endif @@ -3967,8 +3967,8 @@ $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.9 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.9 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.10 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.10 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif endif @@ -4438,8 +4438,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.9 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.9 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.10 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.10 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif endif @@ -4830,8 +4830,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(L ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.9 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.9 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.10 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.10 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so endif endif @@ -5869,8 +5869,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.9 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.9 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.10 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libupb.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.10 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif endif @@ -8630,8 +8630,8 @@ $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBUPB_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libupb.so.9 -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so.9 + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libupb.so.10 -o $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBUPB_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(ADDRESS_SORTING_MERGE_LIBS) $(UPB_MERGE_LIBS) $(GRPC_ABSEIL_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so.10 $(Q) ln -sf $(SHARED_PREFIX)upb$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libupb$(SHARED_VERSION_CORE).so endif endif @@ -9103,6 +9103,21 @@ LIBGRPC_ABSEIL_SRC = \ third_party/abseil-cpp/absl/strings/str_split.cc \ third_party/abseil-cpp/absl/strings/string_view.cc \ third_party/abseil-cpp/absl/strings/substitute.cc \ + third_party/abseil-cpp/absl/time/civil_time.cc \ + third_party/abseil-cpp/absl/time/clock.cc \ + third_party/abseil-cpp/absl/time/duration.cc \ + third_party/abseil-cpp/absl/time/format.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc \ + third_party/abseil-cpp/absl/time/time.cc \ third_party/abseil-cpp/absl/types/bad_optional_access.cc \ diff --git a/build.yaml b/build.yaml index 0339328c36a..371d6809674 100644 --- a/build.yaml +++ b/build.yaml @@ -12,7 +12,7 @@ settings: '#08': Use "-preN" suffixes to identify pre-release versions '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here - core_version: 9.0.0 + core_version: 10.0.0 csharp_major_version: 2 g_stands_for: galactic version: 1.28.0-dev @@ -275,6 +275,8 @@ filegroups: - absl/strings:str_format - absl/strings:strings - absl/types:optional + - absl/time:time + - absl/strings:str_format uses: - gpr_base_headers - name: gpr_base_headers diff --git a/build_config.rb b/build_config.rb index 46cb53f4516..bbbf04812b2 100644 --- a/build_config.rb +++ b/build_config.rb @@ -13,5 +13,5 @@ # limitations under the License. module GrpcBuildConfig - CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-9.dll' + CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-10.dll' end diff --git a/config.m4 b/config.m4 index 549854690b6..336b402e162 100644 --- a/config.m4 +++ b/config.m4 @@ -503,6 +503,21 @@ if test "$PHP_GRPC" != "no"; then third_party/abseil-cpp/absl/strings/str_split.cc \ third_party/abseil-cpp/absl/strings/string_view.cc \ third_party/abseil-cpp/absl/strings/substitute.cc \ + third_party/abseil-cpp/absl/time/civil_time.cc \ + third_party/abseil-cpp/absl/time/clock.cc \ + third_party/abseil-cpp/absl/time/duration.cc \ + third_party/abseil-cpp/absl/time/format.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc \ + third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc \ + third_party/abseil-cpp/absl/time/time.cc \ third_party/abseil-cpp/absl/types/bad_optional_access.cc \ third_party/address_sorting/address_sorting.c \ third_party/address_sorting/address_sorting_posix.c \ @@ -889,6 +904,8 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/strings/internal/str_format) + PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/time) + PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/time/internal/cctz/src) PHP_ADD_BUILD_DIR($ext_builddir/third_party/abseil-cpp/absl/types) PHP_ADD_BUILD_DIR($ext_builddir/third_party/address_sorting) PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl-with-bazel) diff --git a/config.w32 b/config.w32 index 09d57424f7e..e81a813af8f 100644 --- a/config.w32 +++ b/config.w32 @@ -472,6 +472,21 @@ if (PHP_GRPC != "no") { "third_party\\abseil-cpp\\absl\\strings\\str_split.cc " + "third_party\\abseil-cpp\\absl\\strings\\string_view.cc " + "third_party\\abseil-cpp\\absl\\strings\\substitute.cc " + + "third_party\\abseil-cpp\\absl\\time\\civil_time.cc " + + "third_party\\abseil-cpp\\absl\\time\\clock.cc " + + "third_party\\abseil-cpp\\absl\\time\\duration.cc " + + "third_party\\abseil-cpp\\absl\\time\\format.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\civil_time_detail.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_fixed.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_format.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_if.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_impl.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_info.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_libc.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_lookup.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\time_zone_posix.cc " + + "third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src\\zone_info_source.cc " + + "third_party\\abseil-cpp\\absl\\time\\time.cc " + "third_party\\abseil-cpp\\absl\\types\\bad_optional_access.cc " + "third_party\\address_sorting\\address_sorting.c " + "third_party\\address_sorting\\address_sorting_posix.c " + @@ -923,6 +938,10 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\strings\\internal\\str_format"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\time"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\time\\internal"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\time\\internal\\cctz"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\time\\internal\\cctz\\src"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\abseil-cpp\\absl\\types"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\address_sorting"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\third_party\\boringssl-with-bazel"); diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index e8bfc85d55f..efbc7b37ce9 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -218,6 +218,7 @@ Pod::Spec.new do |s| ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/strings/str_format', abseil_version ss.dependency 'abseil/strings/strings', abseil_version + ss.dependency 'abseil/time/time', abseil_version ss.dependency 'abseil/types/optional', abseil_version ss.source_files = 'include/grpcpp/impl/codegen/core_codegen.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index d1eb9401223..a020e2e0a83 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -178,6 +178,7 @@ Pod::Spec.new do |s| ss.dependency 'abseil/memory/memory', abseil_version ss.dependency 'abseil/strings/str_format', abseil_version ss.dependency 'abseil/strings/strings', abseil_version + ss.dependency 'abseil/time/time', abseil_version ss.dependency 'abseil/types/optional', abseil_version ss.compiler_flags = '-DGRPC_SHADOW_BORINGSSL_SYMBOLS' diff --git a/grpc.gemspec b/grpc.gemspec index 584008f58a2..c8cbf110159 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -1002,6 +1002,37 @@ Gem::Specification.new do |s| s.files += %w( third_party/abseil-cpp/absl/strings/strip.h ) s.files += %w( third_party/abseil-cpp/absl/strings/substitute.cc ) s.files += %w( third_party/abseil-cpp/absl/strings/substitute.h ) + s.files += %w( third_party/abseil-cpp/absl/time/civil_time.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/civil_time.h ) + s.files += %w( third_party/abseil-cpp/absl/time/clock.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/clock.h ) + s.files += %w( third_party/abseil-cpp/absl/time/duration.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/format.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc ) + s.files += %w( third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc ) + s.files += %w( third_party/abseil-cpp/absl/time/time.cc ) + s.files += %w( third_party/abseil-cpp/absl/time/time.h ) s.files += %w( third_party/abseil-cpp/absl/types/bad_optional_access.cc ) s.files += %w( third_party/abseil-cpp/absl/types/bad_optional_access.h ) s.files += %w( third_party/abseil-cpp/absl/types/internal/optional.h ) diff --git a/grpc.gyp b/grpc.gyp index 53eb755bec5..d8bba80b271 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -446,6 +446,7 @@ 'absl/strings:str_format', 'absl/strings:strings', 'absl/types:optional', + 'absl/time:time', ], 'sources': [ 'src/core/lib/gpr/alloc.cc', diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 67af9864356..e0b8baf489e 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -425,6 +425,11 @@ typedef struct { size_t* num_creds_md, grpc_status_code* status, const char** error_details); + /** Implements debug string of the given plugin. This method returns an + * allocated string that the caller needs to free using gpr_free() + * */ + char* (*debug_string)(void* state); + /** Destroys the plugin state. */ void (*destroy)(void* state); diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index 08415171d21..9873cba3f7e 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -115,6 +115,7 @@ class CallCredentials : private grpc::GrpcLibraryCodegen { /// Apply this instance's credentials to \a call. virtual bool ApplyToCall(grpc_call* call) = 0; + virtual grpc::string DebugString() { return "CallCredentials{}"; } protected: friend std::shared_ptr CompositeChannelCredentials( @@ -250,6 +251,10 @@ class MetadataCredentialsPlugin { grpc::string_ref service_url, grpc::string_ref method_name, const grpc::AuthContext& channel_auth_context, std::multimap* metadata) = 0; + + virtual grpc::string DebugString() const { + return "MetadataCredentialsPlugin"; + } }; std::shared_ptr MetadataCredentialsFromPlugin( diff --git a/package.xml b/package.xml index d3b65fe366b..029ed2459f8 100644 --- a/package.xml +++ b/package.xml @@ -1004,6 +1004,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc index dc19e234101..8303342aa80 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.cc +++ b/src/core/lib/security/credentials/composite/composite_credentials.cc @@ -116,6 +116,22 @@ void grpc_composite_call_credentials::cancel_get_request_metadata( GRPC_ERROR_UNREF(error); } +std::string grpc_composite_call_credentials::debug_string() const { + std::string debug_str("CompositeCallCredentials"); + if (inner_.empty()) { + return debug_str; + } + debug_str.append("{"); + for (size_t i = 0; i < inner_.size(); ++i) { + debug_str.append(inner_[i]->debug_string()); + if (i != inner_.size() - 1) { + debug_str.append(","); + } + } + debug_str.append("}"); + return debug_str; +} + static size_t get_creds_array_size(const grpc_call_credentials* creds, bool is_composite) { return is_composite diff --git a/src/core/lib/security/credentials/composite/composite_credentials.h b/src/core/lib/security/credentials/composite/composite_credentials.h index 74d55bbc416..d0f22d75e06 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.h +++ b/src/core/lib/security/credentials/composite/composite_credentials.h @@ -21,6 +21,8 @@ #include +#include + #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/security/credentials/credentials.h" @@ -91,6 +93,7 @@ class grpc_composite_call_credentials : public grpc_call_credentials { } const CallCredentialsList& inner() const { return inner_; } + std::string debug_string() const override; private: void push_to_inner(grpc_core::RefCountedPtr creds, diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 65996fd09e4..5c677546479 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -21,6 +21,8 @@ #include +#include + #include #include #include @@ -252,6 +254,8 @@ struct grpc_call_credentials return min_security_level_; } + virtual std::string debug_string() const { return ""; } + const char* type() const { return type_; } private: diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h index 411cfa95b54..a5b87391db9 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.h +++ b/src/core/lib/security/credentials/fake/fake_credentials.h @@ -21,6 +21,8 @@ #include +#include + #include "src/core/lib/security/credentials/credentials.h" #define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \ @@ -75,6 +77,10 @@ class grpc_md_only_test_credentials : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; + std::string debug_string() const override { + return "MD only Test Credentials"; + }; + private: grpc_mdelem md_; bool is_async_; diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc index 94e3d28fd6e..092a306dfe2 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.cc +++ b/src/core/lib/security/credentials/iam/iam_credentials.cc @@ -20,8 +20,6 @@ #include "src/core/lib/security/credentials/iam/iam_credentials.h" -#include - #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/surface/api_trace.h" @@ -30,6 +28,10 @@ #include #include +#include "absl/strings/str_format.h" +#include "src/core/lib/gprpp/ref_counted_ptr.h" +#include "src/core/lib/surface/api_trace.h" + grpc_google_iam_credentials::~grpc_google_iam_credentials() { grpc_credentials_mdelem_array_destroy(&md_array_); } @@ -60,6 +62,9 @@ grpc_google_iam_credentials::grpc_google_iam_credentials( grpc_slice_from_copied_string(authority_selector)); grpc_credentials_mdelem_array_add(&md_array_, md); GRPC_MDELEM_UNREF(md); + debug_string_ = absl::StrFormat( + "GoogleIAMCredentials{Token:%s,AuthoritySelector:%s}", + token != nullptr ? "present" : "absent", authority_selector); } grpc_call_credentials* grpc_google_iam_credentials_create( diff --git a/src/core/lib/security/credentials/iam/iam_credentials.h b/src/core/lib/security/credentials/iam/iam_credentials.h index 36f5ee89307..3d061a1d395 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.h +++ b/src/core/lib/security/credentials/iam/iam_credentials.h @@ -21,6 +21,8 @@ #include +#include + #include "src/core/lib/security/credentials/credentials.h" class grpc_google_iam_credentials : public grpc_call_credentials { @@ -37,9 +39,11 @@ class grpc_google_iam_credentials : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; + std::string debug_string() const override { return debug_string_; } private: grpc_credentials_mdelem_array md_array_; + std::string debug_string_; }; #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc index bed594e5d92..6c39ca48dea 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc @@ -21,7 +21,6 @@ #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" #include -#include #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h index 5af909f44df..16875beb7c4 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -21,6 +21,12 @@ #include +#include + +#include + +#include "absl/strings/str_format.h" +#include "absl/time/time.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/security/credentials/jwt/json_token.h" @@ -43,6 +49,12 @@ class grpc_service_account_jwt_access_credentials const gpr_timespec& jwt_lifetime() const { return jwt_lifetime_; } const grpc_auth_json_key& key() const { return key_; } + std::string debug_string() const override { + return absl::StrFormat("JWTAccessCredentials{ExpirationTime:%s}", + absl::FormatTime(absl::FromUnixMicros( + gpr_timespec_to_micros(jwt_lifetime_)))); + }; + private: void reset_cache(); diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 3a6d19c11ec..5595984931c 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -21,8 +21,6 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" -#include - #include #include #include @@ -358,6 +356,10 @@ grpc_oauth2_token_fetcher_credentials::grpc_oauth2_token_fetcher_credentials() grpc_httpcli_context_init(&httpcli_context_); } +std::string grpc_oauth2_token_fetcher_credentials::debug_string() const { + return "OAuth2TokenFetcherCredentials"; +} + // // Google Compute Engine credentials. // @@ -396,6 +398,12 @@ class grpc_compute_engine_token_fetcher_credentials grpc_resource_quota_unref_internal(resource_quota); } + std::string debug_string() const override { + return absl::StrFormat( + "GoogleComputeEngineTokenFetcherCredentials{%s}", + grpc_oauth2_token_fetcher_credentials::debug_string()); + } + private: grpc_closure http_get_cb_closure_; }; @@ -468,6 +476,12 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token( refresh_token); } +std::string grpc_google_refresh_token_credentials::debug_string() const { + return absl::StrFormat("GoogleRefreshToken{ClientID:%s,%s}", + refresh_token_.client_id, + grpc_oauth2_token_fetcher_credentials::debug_string()); +} + static char* create_loggable_refresh_token(grpc_auth_refresh_token* token) { if (strcmp(token->type, GRPC_AUTH_JSON_TYPE_INVALID) == 0) { return gpr_strdup(""); @@ -540,6 +554,13 @@ class StsTokenFetcherCredentials ~StsTokenFetcherCredentials() override { grpc_uri_destroy(sts_url_); } + std::string debug_string() const override { + return absl::StrFormat( + "StsTokenFetcherCredentials{Path:%s,Authority:%s,%s}", sts_url_->path, + sts_url_->authority, + grpc_oauth2_token_fetcher_credentials::debug_string()); + } + private: void fetch_oauth2(grpc_credentials_metadata_request* metadata_req, grpc_httpcli_context* http_context, @@ -731,6 +752,12 @@ grpc_access_token_credentials::grpc_access_token_credentials( gpr_free(token_md_value); } +std::string grpc_access_token_credentials::debug_string() const { + bool access_token_present = !GRPC_MDISNULL(access_token_md_); + return absl::StrFormat("AccessTokenCredentials{Token:%s}", + access_token_present ? "present" : "absent"); +} + grpc_call_credentials* grpc_access_token_credentials_create( const char* access_token, void* reserved) { GRPC_API_TRACE( diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 97579522950..48562a66763 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -21,7 +21,11 @@ #include +#include + #include +#include "absl/strings/str_format.h" +#include "absl/time/time.h" #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/uri/uri_parser.h" @@ -84,6 +88,7 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials { void on_http_response(grpc_credentials_metadata_request* r, grpc_error* error); + std::string debug_string() const override; protected: virtual void fetch_oauth2(grpc_credentials_metadata_request* req, @@ -112,6 +117,8 @@ class grpc_google_refresh_token_credentials final return refresh_token_; } + std::string debug_string() const override; + protected: void fetch_oauth2(grpc_credentials_metadata_request* req, grpc_httpcli_context* httpcli_context, @@ -138,6 +145,8 @@ class grpc_access_token_credentials final : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; + std::string debug_string() const override; + private: grpc_mdelem access_token_md_; }; diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 24351bcf42b..f078f727580 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -42,6 +42,16 @@ grpc_plugin_credentials::~grpc_plugin_credentials() { } } +std::string grpc_plugin_credentials::debug_string() const { + if (plugin_.debug_string != nullptr) { + char* debug_c_str = plugin_.debug_string(plugin_.state); + std::string debug_str(debug_c_str); + gpr_free(debug_c_str); + return debug_str; + } + return ""; +} + void grpc_plugin_credentials::pending_request_remove_locked( pending_request* pending_request) { if (pending_request->prev == nullptr) { diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h index fb9a7b71348..413f767d2e3 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.h +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h @@ -59,6 +59,8 @@ struct grpc_plugin_credentials final : public grpc_call_credentials { // cancelled before completion. void pending_request_complete(pending_request* r); + std::string debug_string() const override; + private: void pending_request_remove_locked(pending_request* pending_request); diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc index 9b512a8bcde..3362b23008b 100644 --- a/src/core/lib/surface/version.cc +++ b/src/core/lib/surface/version.cc @@ -23,6 +23,6 @@ #include -const char* grpc_version_string(void) { return "9.0.0"; } +const char* grpc_version_string(void) { return "10.0.0"; } const char* grpc_g_stands_for(void) { return "galactic"; } diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 33f56d3c340..3d4e43da4d7 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -257,6 +258,7 @@ std::shared_ptr MetadataCredentialsFromPlugin( new grpc::MetadataCredentialsPluginWrapper(std::move(plugin)); grpc_metadata_credentials_plugin c_plugin = { grpc::MetadataCredentialsPluginWrapper::GetMetadata, + grpc::MetadataCredentialsPluginWrapper::DebugString, grpc::MetadataCredentialsPluginWrapper::Destroy, wrapper, type}; return WrapCallCredentials(grpc_metadata_credentials_create_from_plugin( c_plugin, min_security_level, nullptr)); @@ -379,6 +381,7 @@ std::shared_ptr MetadataCredentialsFromPlugin( new grpc::MetadataCredentialsPluginWrapper(std::move(plugin)); grpc_metadata_credentials_plugin c_plugin = { grpc::MetadataCredentialsPluginWrapper::GetMetadata, + grpc::MetadataCredentialsPluginWrapper::DebugString, grpc::MetadataCredentialsPluginWrapper::Destroy, wrapper, type}; return WrapCallCredentials(grpc_metadata_credentials_create_from_plugin( c_plugin, GRPC_PRIVACY_AND_INTEGRITY, nullptr)); @@ -395,6 +398,14 @@ void DeleteWrapper(void* wrapper, grpc_error* /*ignored*/) { } } // namespace +char* MetadataCredentialsPluginWrapper::DebugString(void* wrapper) { + GPR_ASSERT(wrapper); + MetadataCredentialsPluginWrapper* w = + static_cast(wrapper); + char* debug_str = gpr_strdup(w->plugin_->DebugString().c_str()); + return debug_str; +} + void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) { if (wrapper == nullptr) return; grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h index 2c817270ad9..c8f8529338d 100644 --- a/src/cpp/client/secure_credentials.h +++ b/src/cpp/client/secure_credentials.h @@ -65,6 +65,10 @@ class SecureCallCredentials final : public CallCredentials { bool ApplyToCall(grpc_call* call) override; SecureCallCredentials* AsSecureCredentials() override { return this; } + grpc::string DebugString() override { + return "SecureCallCredentials{" + grpc::string(c_creds_->debug_string()) + + "}"; + } private: grpc_call_credentials* const c_creds_; @@ -93,6 +97,7 @@ class MetadataCredentialsPluginWrapper final : private GrpcLibraryCodegen { grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t* num_creds_md, grpc_status_code* status, const char** error_details); + static char* DebugString(void* wrapper); explicit MetadataCredentialsPluginWrapper( std::unique_ptr plugin); diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h index 8a9cd1d5dec..5b6a64920dd 100644 --- a/src/objective-c/tests/version.h +++ b/src/objective-c/tests/version.h @@ -23,4 +23,4 @@ // `tools/buildgen/generate_projects.sh`. #define GRPC_OBJC_VERSION_STRING @"1.28.0-dev" -#define GRPC_C_VERSION_STRING @"9.0.0" +#define GRPC_C_VERSION_STRING @"10.0.0" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 1fbf25a1444..c9e7e04cbb0 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -471,6 +471,21 @@ CORE_SOURCE_FILES = [ 'third_party/abseil-cpp/absl/strings/str_split.cc', 'third_party/abseil-cpp/absl/strings/string_view.cc', 'third_party/abseil-cpp/absl/strings/substitute.cc', + 'third_party/abseil-cpp/absl/time/civil_time.cc', + 'third_party/abseil-cpp/absl/time/clock.cc', + 'third_party/abseil-cpp/absl/time/duration.cc', + 'third_party/abseil-cpp/absl/time/format.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc', + 'third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc', + 'third_party/abseil-cpp/absl/time/time.cc', 'third_party/abseil-cpp/absl/types/bad_optional_access.cc', 'third_party/address_sorting/address_sorting.c', 'third_party/address_sorting/address_sorting_posix.c', diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index b58973d4c34..d938d46f6c3 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -613,6 +613,9 @@ static void test_compute_engine_creds_success() { grpc_core::ExecCtx exec_ctx; expected_md emd[] = { {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; + const char expected_creds_debug_string[] = + "GoogleComputeEngineTokenFetcherCredentials{" + "OAuth2TokenFetcherCredentials}"; grpc_call_credentials* creds = grpc_google_compute_engine_credentials_create(nullptr); grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, @@ -636,12 +639,17 @@ static void test_compute_engine_creds_success() { run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); } static void test_compute_engine_creds_failure(void) { grpc_core::ExecCtx exec_ctx; + const char expected_creds_debug_string[] = + "GoogleComputeEngineTokenFetcherCredentials{" + "OAuth2TokenFetcherCredentials}"; request_metadata_state* state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Error occurred when fetching oauth2 token."), @@ -653,6 +661,8 @@ static void test_compute_engine_creds_failure(void) { grpc_httpcli_set_override(compute_engine_httpcli_get_failure_override, httpcli_post_should_not_be_called); run_request_metadata_test(creds, auth_md_ctx, state); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); } @@ -705,6 +715,9 @@ static void test_refresh_token_creds_success(void) { grpc_core::ExecCtx exec_ctx; expected_md emd[] = { {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; + const char expected_creds_debug_string[] = + "GoogleRefreshToken{ClientID:32555999999.apps.googleusercontent.com," + "OAuth2TokenFetcherCredentials}"; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr, nullptr}; grpc_call_credentials* creds = grpc_google_refresh_token_credentials_create( @@ -728,6 +741,8 @@ static void test_refresh_token_creds_success(void) { httpcli_post_should_not_be_called); run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -735,6 +750,9 @@ static void test_refresh_token_creds_success(void) { static void test_refresh_token_creds_failure(void) { grpc_core::ExecCtx exec_ctx; + const char expected_creds_debug_string[] = + "GoogleRefreshToken{ClientID:32555999999.apps.googleusercontent.com," + "OAuth2TokenFetcherCredentials}"; request_metadata_state* state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Error occurred when fetching oauth2 token."), @@ -746,6 +764,9 @@ static void test_refresh_token_creds_failure(void) { grpc_httpcli_set_override(httpcli_get_should_not_be_called, token_httpcli_post_failure); run_request_metadata_test(creds, auth_md_ctx, state); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); } @@ -939,6 +960,9 @@ static void test_sts_creds_success(void) { grpc_core::ExecCtx exec_ctx; expected_md emd[] = { {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; + const char expected_creds_debug_string[] = + "StsTokenFetcherCredentials{Path:/v1/" + "token-exchange,Authority:foo.com:5555,OAuth2TokenFetcherCredentials}"; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr, nullptr}; char* subject_token_path = write_tmp_jwt_file(test_signed_jwt); @@ -975,6 +999,8 @@ static void test_sts_creds_success(void) { httpcli_post_should_not_be_called); run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -1021,6 +1047,9 @@ static void test_sts_creds_no_actor_token_success(void) { grpc_core::ExecCtx exec_ctx; expected_md emd[] = { {"authorization", "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_"}}; + const char expected_creds_debug_string[] = + "StsTokenFetcherCredentials{Path:/v1/" + "token-exchange,Authority:foo.com:5555,OAuth2TokenFetcherCredentials}"; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, nullptr, nullptr}; char* subject_token_path = write_tmp_jwt_file(test_signed_jwt); @@ -1056,6 +1085,8 @@ static void test_sts_creds_no_actor_token_success(void) { httpcli_post_should_not_be_called); run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -1063,6 +1094,9 @@ static void test_sts_creds_no_actor_token_success(void) { } static void test_sts_creds_load_token_failure(void) { + const char expected_creds_debug_string[] = + "StsTokenFetcherCredentials{Path:/v1/" + "token-exchange,Authority:foo.com:5555,OAuth2TokenFetcherCredentials}"; grpc_core::ExecCtx exec_ctx; request_metadata_state* state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_STATIC_STRING( @@ -1086,12 +1120,18 @@ static void test_sts_creds_load_token_failure(void) { grpc_httpcli_set_override(httpcli_get_should_not_be_called, httpcli_post_should_not_be_called); run_request_metadata_test(creds, auth_md_ctx, state); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); gpr_free(test_signed_jwt_path); } static void test_sts_creds_http_failure(void) { + const char expected_creds_debug_string[] = + "StsTokenFetcherCredentials{Path:/v1/" + "token-exchange,Authority:foo.com:5555,OAuth2TokenFetcherCredentials}"; grpc_core::ExecCtx exec_ctx; request_metadata_state* state = make_request_metadata_state( GRPC_ERROR_CREATE_FROM_STATIC_STRING( @@ -1116,6 +1156,8 @@ static void test_sts_creds_http_failure(void) { grpc_httpcli_set_override(httpcli_get_should_not_be_called, token_httpcli_post_failure); run_request_metadata_test(creds, auth_md_ctx, state); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); gpr_free(test_signed_jwt_path); @@ -1176,7 +1218,8 @@ static grpc_service_account_jwt_access_credentials* creds_as_jwt( static void test_jwt_creds_lifetime(void) { char* json_key_string = test_json_key_str(); - + const char expected_creds_debug_string_prefix[] = + "JWTAccessCredentials{ExpirationTime:"; // Max lifetime. grpc_call_credentials* jwt_creds = grpc_service_account_jwt_access_credentials_create( @@ -1185,6 +1228,9 @@ static void test_jwt_creds_lifetime(void) { grpc_max_auth_token_lifetime()) == 0); /* Check security level. */ GPR_ASSERT(jwt_creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); + GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix))); grpc_call_credentials_release(jwt_creds); // Shorter lifetime. @@ -1194,6 +1240,9 @@ static void test_jwt_creds_lifetime(void) { json_key_string, token_lifetime, nullptr); GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), token_lifetime) == 0); + GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix))); grpc_call_credentials_release(jwt_creds); // Cropped lifetime. @@ -1203,12 +1252,18 @@ static void test_jwt_creds_lifetime(void) { json_key_string, token_lifetime, nullptr); GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), grpc_max_auth_token_lifetime()) == 0); + GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix))); grpc_call_credentials_release(jwt_creds); gpr_free(json_key_string); } static void test_jwt_creds_success(void) { + const char expected_creds_debug_string_prefix[] = + "JWTAccessCredentials{ExpirationTime:"; + char* json_key_string = test_json_key_str(); grpc_core::ExecCtx exec_ctx; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, @@ -1243,6 +1298,9 @@ static void test_jwt_creds_success(void) { grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success); run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); + GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, + creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix))); creds->Unref(); gpr_free(json_key_string); @@ -1251,6 +1309,8 @@ static void test_jwt_creds_success(void) { } static void test_jwt_creds_signing_failure(void) { + const char expected_creds_debug_string_prefix[] = + "JWTAccessCredentials{ExpirationTime:"; char* json_key_string = test_json_key_str(); grpc_core::ExecCtx exec_ctx; grpc_auth_metadata_context auth_md_ctx = {test_service_url, test_method, @@ -1266,6 +1326,10 @@ static void test_jwt_creds_signing_failure(void) { run_request_metadata_test(creds, auth_md_ctx, state); gpr_free(json_key_string); + GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, + creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix))); + creds->Unref(); grpc_jwt_encode_and_sign_set_override(nullptr); } @@ -1513,7 +1577,29 @@ static void plugin_destroy(void* state) { *s = PLUGIN_DESTROY_CALLED_STATE; } +static char* plugin_debug_string(void* state) { + plugin_state* s = static_cast(state); + char* ret = nullptr; + switch (*s) { + case PLUGIN_INITIAL_STATE: + gpr_asprintf(&ret, "TestPluginCredentials{state:INITIAL}"); + break; + case PLUGIN_GET_METADATA_CALLED_STATE: + gpr_asprintf(&ret, "TestPluginCredentials{state:GET_METADATA_CALLED}"); + break; + case PLUGIN_DESTROY_CALLED_STATE: + gpr_asprintf(&ret, "TestPluginCredentials{state:DESTROY}"); + break; + default: + gpr_asprintf(&ret, "TestPluginCredentials{state:UNKNOWN}"); + break; + } + return ret; +} + static void test_metadata_plugin_success(void) { + const char expected_creds_debug_string[] = + "TestPluginCredentials{state:GET_METADATA_CALLED}"; plugin_state state = PLUGIN_INITIAL_STATE; grpc_metadata_credentials_plugin plugin; grpc_core::ExecCtx exec_ctx; @@ -1525,6 +1611,7 @@ static void test_metadata_plugin_success(void) { plugin.state = &state; plugin.get_metadata = plugin_get_metadata_success; plugin.destroy = plugin_destroy; + plugin.debug_string = plugin_debug_string; grpc_call_credentials* creds = grpc_metadata_credentials_create_from_plugin( plugin, GRPC_PRIVACY_AND_INTEGRITY, nullptr); @@ -1533,12 +1620,17 @@ static void test_metadata_plugin_success(void) { GPR_ASSERT(state == PLUGIN_INITIAL_STATE); run_request_metadata_test(creds, auth_md_ctx, md_state); GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); } static void test_metadata_plugin_failure(void) { + const char expected_creds_debug_string[] = + "TestPluginCredentials{state:GET_METADATA_CALLED}"; + plugin_state state = PLUGIN_INITIAL_STATE; grpc_metadata_credentials_plugin plugin; grpc_core::ExecCtx exec_ctx; @@ -1555,12 +1647,15 @@ static void test_metadata_plugin_failure(void) { plugin.state = &state; plugin.get_metadata = plugin_get_metadata_failure; plugin.destroy = plugin_destroy; + plugin.debug_string = plugin_debug_string; grpc_call_credentials* creds = grpc_metadata_credentials_create_from_plugin( plugin, GRPC_PRIVACY_AND_INTEGRITY, nullptr); GPR_ASSERT(state == PLUGIN_INITIAL_STATE); run_request_metadata_test(creds, auth_md_ctx, md_state); GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); + GPR_ASSERT( + !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); creds->Unref(); GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); @@ -1599,6 +1694,8 @@ static void test_get_well_known_google_credentials_file_path(void) { } static void test_channel_creds_duplicate_without_call_creds(void) { + const char expected_creds_debug_string[] = + "AccessTokenCredentials{Token:present}"; grpc_core::ExecCtx exec_ctx; grpc_channel_credentials* channel_creds = @@ -1614,6 +1711,9 @@ static void test_channel_creds_duplicate_without_call_creds(void) { grpc_channel_credentials* composite_creds = grpc_composite_channel_credentials_create(channel_creds, call_creds, nullptr); + GPR_ASSERT(!gpr_stricmp(call_creds->debug_string().c_str(), + expected_creds_debug_string)); + call_creds->Unref(); dup = composite_creds->duplicate_without_call_credentials(); GPR_ASSERT(dup == channel_creds); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 33113942151..1c20e7da731 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -31,10 +31,12 @@ #include #include #include +#include #include #include +#include "absl/strings/str_format.h" #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/lib/gpr/env.h" #include "src/core/lib/iomgr/iomgr.h" @@ -85,6 +87,58 @@ bool CheckIsLocalhost(const grpc::string& addr) { const char kTestCredsPluginErrorMsg[] = "Could not find plugin metadata."; +const char kFakeToken[] = "fake_token"; +const char kFakeSelector[] = "fake_selector"; +const char kExpectedFakeCredsDebugString[] = + "SecureCallCredentials{GoogleIAMCredentials{Token:present," + "AuthoritySelector:fake_selector}}"; + +const char kWrongToken[] = "wrong_token"; +const char kWrongSelector[] = "wrong_selector"; +const char kExpectedWrongCredsDebugString[] = + "SecureCallCredentials{GoogleIAMCredentials{Token:present," + "AuthoritySelector:wrong_selector}}"; + +const char kFakeToken1[] = "fake_token1"; +const char kFakeSelector1[] = "fake_selector1"; +const char kExpectedFakeCreds1DebugString[] = + "SecureCallCredentials{GoogleIAMCredentials{Token:present," + "AuthoritySelector:fake_selector1}}"; + +const char kFakeToken2[] = "fake_token2"; +const char kFakeSelector2[] = "fake_selector2"; +const char kExpectedFakeCreds2DebugString[] = + "SecureCallCredentials{GoogleIAMCredentials{Token:present," + "AuthoritySelector:fake_selector2}}"; + +const char kExpectedAuthMetadataPluginKeyFailureCredsDebugString[] = + "SecureCallCredentials{TestMetadataCredentials{key:TestPluginMetadata," + "value:Does not matter, will fail the key is invalid.}}"; +const char kExpectedAuthMetadataPluginValueFailureCredsDebugString[] = + "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-metadata," + "value:With illegal \n value.}}"; +const char kExpectedAuthMetadataPluginWithDeadlineCredsDebugString[] = + "SecureCallCredentials{TestMetadataCredentials{key:meta_key,value:Does not " + "matter}}"; +const char kExpectedNonBlockingAuthMetadataPluginFailureCredsDebugString[] = + "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-metadata," + "value:Does not matter, will fail anyway (see 3rd param)}}"; +const char + kExpectedNonBlockingAuthMetadataPluginAndProcessorSuccessCredsDebugString + [] = "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-" + "metadata,value:Dr Jekyll}}"; +const char + kExpectedNonBlockingAuthMetadataPluginAndProcessorFailureCredsDebugString + [] = "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-" + "metadata,value:Mr Hyde}}"; +const char kExpectedBlockingAuthMetadataPluginFailureCredsDebugString[] = + "SecureCallCredentials{TestMetadataCredentials{key:test-plugin-metadata," + "value:Does not matter, will fail anyway (see 3rd param)}}"; +const char kExpectedCompositeCallCredsDebugString[] = + "SecureCallCredentials{CompositeCallCredentials{TestMetadataCredentials{" + "key:call-creds-key1,value:call-creds-val1},TestMetadataCredentials{key:" + "call-creds-key2,value:call-creds-val2}}}"; + class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin { public: static const char kGoodMetadataKey[]; @@ -123,6 +177,11 @@ class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin { } } + grpc::string DebugString() const override { + return absl::StrFormat("TestMetadataCredentials{key:%s,value:%s}", + metadata_key_.c_str(), metadata_value_.c_str()); + } + private: grpc::string metadata_key_; grpc::string metadata_value_; @@ -1760,7 +1819,7 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { EchoResponse response; ClientContext context; std::shared_ptr creds = - GoogleIAMCredentials("fake_token", "fake_selector"); + GoogleIAMCredentials(kFakeToken, kFakeSelector); context.set_credentials(creds); request.set_message("Hello"); request.mutable_param()->set_echo_metadata(true); @@ -1770,10 +1829,12 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { EXPECT_TRUE(s.ok()); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - "fake_token")); + kFakeToken)); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - "fake_selector")); + kFakeSelector)); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedFakeCredsDebugString); } class CredentialsInterceptor : public experimental::Interceptor { @@ -1784,7 +1845,7 @@ class CredentialsInterceptor : public experimental::Interceptor { if (methods->QueryInterceptionHookPoint( experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) { std::shared_ptr creds = - GoogleIAMCredentials("fake_token", "fake_selector"); + GoogleIAMCredentials(kFakeToken, kFakeSelector); info_->client_context()->set_credentials(creds); } methods->Proceed(); @@ -1824,10 +1885,12 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterception) { EXPECT_TRUE(s.ok()); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - "fake_token")); + kFakeToken)); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - "fake_selector")); + kFakeSelector)); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedFakeCredsDebugString); } TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) { @@ -1844,9 +1907,11 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) { EchoResponse response; ClientContext context; std::shared_ptr creds1 = - GoogleIAMCredentials("wrong_token", "wrong_selector"); + GoogleIAMCredentials(kWrongToken, kWrongSelector); context.set_credentials(creds1); EXPECT_EQ(context.credentials(), creds1); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedWrongCredsDebugString); request.set_message("Hello"); request.mutable_param()->set_echo_metadata(true); @@ -1855,10 +1920,12 @@ TEST_P(SecureEnd2endTest, CallCredentialsInterceptionWithSetCredentials) { EXPECT_TRUE(s.ok()); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - "fake_token")); + kFakeToken)); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - "fake_selector")); + kFakeSelector)); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedFakeCredsDebugString); } TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { @@ -1868,11 +1935,13 @@ TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { EchoResponse response; ClientContext context; std::shared_ptr creds1 = - GoogleIAMCredentials("fake_token1", "fake_selector1"); + GoogleIAMCredentials(kFakeToken1, kFakeSelector1); context.set_credentials(creds1); EXPECT_EQ(context.credentials(), creds1); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedFakeCreds1DebugString); std::shared_ptr creds2 = - GoogleIAMCredentials("fake_token2", "fake_selector2"); + GoogleIAMCredentials(kFakeToken2, kFakeSelector2); context.set_credentials(creds2); EXPECT_EQ(context.credentials(), creds2); request.set_message("Hello"); @@ -1881,16 +1950,18 @@ TEST_P(SecureEnd2endTest, OverridePerCallCredentials) { Status s = stub_->Echo(&context, request, &response); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - "fake_token2")); + kFakeToken2)); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - "fake_selector2")); + kFakeSelector2)); EXPECT_FALSE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, - "fake_token1")); + kFakeToken1)); EXPECT_FALSE(MetadataContains(context.GetServerTrailingMetadata(), GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, - "fake_selector1")); + kFakeSelector1)); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedFakeCreds2DebugString); EXPECT_EQ(request.message(), response.message()); EXPECT_TRUE(s.ok()); } @@ -1912,6 +1983,8 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginKeyFailure) { Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedAuthMetadataPluginKeyFailureCredsDebugString); } TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) { @@ -1930,6 +2003,8 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginValueFailure) { Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); EXPECT_EQ(s.error_code(), StatusCode::UNAVAILABLE); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedAuthMetadataPluginValueFailureCredsDebugString); } TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { @@ -1954,6 +2029,8 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithDeadline) { EXPECT_TRUE(s.error_code() == StatusCode::DEADLINE_EXCEEDED || s.error_code() == StatusCode::UNAVAILABLE); } + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedAuthMetadataPluginWithDeadlineCredsDebugString); } TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) { @@ -1981,6 +2058,8 @@ TEST_P(SecureEnd2endTest, AuthMetadataPluginWithCancel) { s.error_code() == StatusCode::UNAVAILABLE); } cancel_thread.join(); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedAuthMetadataPluginWithDeadlineCredsDebugString); } TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) { @@ -2003,6 +2082,8 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginFailure) { EXPECT_EQ(s.error_message(), grpc::string("Getting metadata from plugin failed with error: ") + kTestCredsPluginErrorMsg); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedNonBlockingAuthMetadataPluginFailureCredsDebugString); } TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorSuccess) { @@ -2029,6 +2110,9 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorSuccess) { EXPECT_FALSE(MetadataContains( context.GetServerTrailingMetadata(), GRPC_AUTHORIZATION_METADATA_KEY, grpc::string("Bearer ") + TestAuthMetadataProcessor::kGoodGuy)); + EXPECT_EQ( + context.credentials()->DebugString(), + kExpectedNonBlockingAuthMetadataPluginAndProcessorSuccessCredsDebugString); } TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorFailure) { @@ -2045,6 +2129,9 @@ TEST_P(SecureEnd2endTest, NonBlockingAuthMetadataPluginAndProcessorFailure) { Status s = stub_->Echo(&context, request, &response); EXPECT_FALSE(s.ok()); EXPECT_EQ(s.error_code(), StatusCode::UNAUTHENTICATED); + EXPECT_EQ( + context.credentials()->DebugString(), + kExpectedNonBlockingAuthMetadataPluginAndProcessorFailureCredsDebugString); } TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) { @@ -2067,6 +2154,8 @@ TEST_P(SecureEnd2endTest, BlockingAuthMetadataPluginFailure) { EXPECT_EQ(s.error_message(), grpc::string("Getting metadata from plugin failed with error: ") + kTestCredsPluginErrorMsg); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedBlockingAuthMetadataPluginFailureCredsDebugString); } TEST_P(SecureEnd2endTest, CompositeCallCreds) { @@ -2098,6 +2187,8 @@ TEST_P(SecureEnd2endTest, CompositeCallCreds) { kMetadataKey1, kMetadataVal1)); EXPECT_TRUE(MetadataContains(context.GetServerTrailingMetadata(), kMetadataKey2, kMetadataVal2)); + EXPECT_EQ(context.credentials()->DebugString(), + kExpectedCompositeCallCredsDebugString); } TEST_P(SecureEnd2endTest, ClientAuthContext) { diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 9ab5b3e429c..f46683470da 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 9.0.0 +PROJECT_NUMBER = 10.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 04cb62c32bc..dcced8d2f3e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 9.0.0 +PROJECT_NUMBER = 10.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From ede2ffc1a8b845acaad157c1299d9fdc91313e8a Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Wed, 26 Feb 2020 12:51:35 -0800 Subject: [PATCH 2/6] Addressed Mark's comments --- BUILD.gn | 2 +- CMakeLists.txt | 12 ++-- build.yaml | 3 +- grpc.gyp | 2 +- include/grpcpp/security/credentials_impl.h | 6 +- .../composite/composite_credentials.cc | 20 +++---- .../lib/security/credentials/credentials.h | 4 +- .../credentials/oauth2/oauth2_credentials.cc | 1 + .../credentials/oauth2/oauth2_credentials.h | 2 - .../credentials/plugin/plugin_credentials.cc | 10 +++- src/cpp/client/secure_credentials.cc | 3 +- src/cpp/client/secure_credentials.h | 5 +- test/core/security/credentials_test.cc | 56 +++++++++---------- 13 files changed, 64 insertions(+), 62 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 122c579bd5b..c3fbed3adf7 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -165,8 +165,8 @@ config("grpc_config") { ":absl/memory:memory", ":absl/strings:str_format", ":absl/strings:strings", - ":absl/types:optional", ":absl/time:time", + ":absl/types:optional", ] public_configs = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 5535b943c0e..7178420f21b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1447,8 +1447,8 @@ target_link_libraries(gpr absl::memory absl::str_format absl::strings - absl::optional absl::time + absl::optional ) if(_gRPC_PLATFORM_ANDROID) target_link_libraries(gpr @@ -18579,7 +18579,7 @@ generate_pkgconfig( "gRPC platform support library" "${gRPC_CORE_VERSION}" "" - "-lgpr -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgpr -labsl_bad_optional_access -labsl_time -labsl_time_zone -labsl_civil_time -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "gpr.pc") @@ -18589,7 +18589,7 @@ generate_pkgconfig( "high performance general RPC framework" "${gRPC_CORE_VERSION}" "gpr openssl" - "-lgrpc -laddress_sorting -lupb -lcares -lz -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc -laddress_sorting -lupb -lcares -lz -labsl_bad_optional_access -labsl_time -labsl_time_zone -labsl_civil_time -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc.pc") @@ -18599,7 +18599,7 @@ generate_pkgconfig( "high performance general RPC framework without SSL" "${gRPC_CORE_VERSION}" "gpr" - "-lgrpc_unsecure -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc_unsecure -labsl_bad_optional_access -labsl_time -labsl_time_zone -labsl_civil_time -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc_unsecure.pc") @@ -18609,7 +18609,7 @@ generate_pkgconfig( "C++ wrapper for gRPC" "${PACKAGE_VERSION}" "grpc" - "-lgrpc++ -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc++ -labsl_bad_optional_access -labsl_time -labsl_time_zone -labsl_civil_time -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc++.pc") @@ -18619,6 +18619,6 @@ generate_pkgconfig( "C++ wrapper for gRPC without SSL" "${PACKAGE_VERSION}" "grpc_unsecure" - "-lgrpc++_unsecure -labsl_time -labsl_time_zone -labsl_civil_time -labsl_bad_optional_access -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" + "-lgrpc++_unsecure -labsl_bad_optional_access -labsl_time -labsl_time_zone -labsl_civil_time -labsl_str_format_internal -labsl_strings -labsl_strings_internal -labsl_base -labsl_spinlock_wait -labsl_dynamic_annotations -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity" "" "grpc++_unsecure.pc") diff --git a/build.yaml b/build.yaml index 371d6809674..5b442c8b391 100644 --- a/build.yaml +++ b/build.yaml @@ -274,9 +274,8 @@ filegroups: - absl/memory:memory - absl/strings:str_format - absl/strings:strings - - absl/types:optional - absl/time:time - - absl/strings:str_format + - absl/types:optional uses: - gpr_base_headers - name: gpr_base_headers diff --git a/grpc.gyp b/grpc.gyp index d8bba80b271..5c50f3d95d0 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -445,8 +445,8 @@ 'absl/memory:memory', 'absl/strings:str_format', 'absl/strings:strings', - 'absl/types:optional', 'absl/time:time', + 'absl/types:optional', ], 'sources': [ 'src/core/lib/gpr/alloc.cc', diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index 9873cba3f7e..234ea042da9 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -115,7 +115,9 @@ class CallCredentials : private grpc::GrpcLibraryCodegen { /// Apply this instance's credentials to \a call. virtual bool ApplyToCall(grpc_call* call) = 0; - virtual grpc::string DebugString() { return "CallCredentials{}"; } + virtual grpc::string DebugString() { + return "CallCredentials did not provide a debug string"; + } protected: friend std::shared_ptr CompositeChannelCredentials( @@ -253,7 +255,7 @@ class MetadataCredentialsPlugin { std::multimap* metadata) = 0; virtual grpc::string DebugString() const { - return "MetadataCredentialsPlugin"; + return "MetadataCredentialsPlugin did not provide a debug string"; } }; diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc index 8303342aa80..955e19f2ede 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.cc +++ b/src/core/lib/security/credentials/composite/composite_credentials.cc @@ -22,7 +22,10 @@ #include #include +#include +#include "absl/strings/str_cat.h" +#include "absl/strings/str_join.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/surface/api_trace.h" @@ -117,19 +120,12 @@ void grpc_composite_call_credentials::cancel_get_request_metadata( } std::string grpc_composite_call_credentials::debug_string() const { - std::string debug_str("CompositeCallCredentials"); - if (inner_.empty()) { - return debug_str; + std::vector outputs; + for (auto& inner_cred : inner_) { + outputs.emplace_back(inner_cred->debug_string()); } - debug_str.append("{"); - for (size_t i = 0; i < inner_.size(); ++i) { - debug_str.append(inner_[i]->debug_string()); - if (i != inner_.size() - 1) { - debug_str.append(","); - } - } - debug_str.append("}"); - return debug_str; + return absl::StrCat("CompositeCallCredentials{", absl::StrJoin(outputs, ","), + "}"); } static size_t get_creds_array_size(const grpc_call_credentials* creds, diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 5c677546479..a7a353ec217 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -254,7 +254,9 @@ struct grpc_call_credentials return min_security_level_; } - virtual std::string debug_string() const { return ""; } + virtual std::string debug_string() const { + return "grpc_call_credentials did not provide debug string"; + } const char* type() const { return type_; } diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 5595984931c..573aec264c7 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -28,6 +28,7 @@ #include #include +#include "absl/strings/str_format.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 48562a66763..ee03fa76223 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -24,8 +24,6 @@ #include #include -#include "absl/strings/str_format.h" -#include "absl/time/time.h" #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/uri/uri_parser.h" diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index f078f727580..95074947670 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -43,13 +43,17 @@ grpc_plugin_credentials::~grpc_plugin_credentials() { } std::string grpc_plugin_credentials::debug_string() const { + std::string debug_str; if (plugin_.debug_string != nullptr) { char* debug_c_str = plugin_.debug_string(plugin_.state); - std::string debug_str(debug_c_str); + if (strlen(debug_c_str) != 0) { + debug_str = debug_c_str; + } gpr_free(debug_c_str); - return debug_str; } - return ""; + return debug_str.empty() + ? "grpc_plugin_credentials did not provide a debug string" + : debug_str; } void grpc_plugin_credentials::pending_request_remove_locked( diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 3d4e43da4d7..b21d5102e23 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -402,8 +402,7 @@ char* MetadataCredentialsPluginWrapper::DebugString(void* wrapper) { GPR_ASSERT(wrapper); MetadataCredentialsPluginWrapper* w = static_cast(wrapper); - char* debug_str = gpr_strdup(w->plugin_->DebugString().c_str()); - return debug_str; + return gpr_strdup(w->plugin_->DebugString().c_str()); } void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) { diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h index c8f8529338d..84852a47942 100644 --- a/src/cpp/client/secure_credentials.h +++ b/src/cpp/client/secure_credentials.h @@ -26,6 +26,7 @@ #include #include +#include "absl/strings/str_cat.h" #include "src/core/lib/security/credentials/credentials.h" #include "src/cpp/server/thread_pool_interface.h" @@ -66,8 +67,8 @@ class SecureCallCredentials final : public CallCredentials { bool ApplyToCall(grpc_call* call) override; SecureCallCredentials* AsSecureCredentials() override { return this; } grpc::string DebugString() override { - return "SecureCallCredentials{" + grpc::string(c_creds_->debug_string()) + - "}"; + return absl::StrCat("SecureCallCredentials{", + grpc::string(c_creds_->debug_string()), "}"); } private: diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index d938d46f6c3..3299259d1ee 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -640,7 +640,7 @@ static void test_compute_engine_creds_success() { grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); } @@ -662,7 +662,7 @@ static void test_compute_engine_creds_failure(void) { httpcli_post_should_not_be_called); run_request_metadata_test(creds, auth_md_ctx, state); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); } @@ -742,7 +742,7 @@ static void test_refresh_token_creds_success(void) { run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -765,7 +765,7 @@ static void test_refresh_token_creds_failure(void) { token_httpcli_post_failure); run_request_metadata_test(creds, auth_md_ctx, state); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -1000,7 +1000,7 @@ static void test_sts_creds_success(void) { run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -1086,7 +1086,7 @@ static void test_sts_creds_no_actor_token_success(void) { run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -1121,7 +1121,7 @@ static void test_sts_creds_load_token_failure(void) { httpcli_post_should_not_be_called); run_request_metadata_test(creds, auth_md_ctx, state); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); @@ -1157,7 +1157,7 @@ static void test_sts_creds_http_failure(void) { token_httpcli_post_failure); run_request_metadata_test(creds, auth_md_ctx, state); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); grpc_httpcli_set_override(nullptr, nullptr); gpr_free(test_signed_jwt_path); @@ -1183,7 +1183,7 @@ static void validate_jwt_encode_and_sign_params( "777-abaslkan11hlb6nmim3bpspl31ud@developer." "gserviceaccount.com") == 0); if (scope != nullptr) GPR_ASSERT(strcmp(scope, test_scope) == 0); - GPR_ASSERT(!gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime())); + GPR_ASSERT(gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()) == 0); } static char* encode_and_sign_jwt_success(const grpc_auth_json_key* json_key, @@ -1228,9 +1228,9 @@ static void test_jwt_creds_lifetime(void) { grpc_max_auth_token_lifetime()) == 0); /* Check security level. */ GPR_ASSERT(jwt_creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); - GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix))); + GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); grpc_call_credentials_release(jwt_creds); // Shorter lifetime. @@ -1240,9 +1240,9 @@ static void test_jwt_creds_lifetime(void) { json_key_string, token_lifetime, nullptr); GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), token_lifetime) == 0); - GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix))); + GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); grpc_call_credentials_release(jwt_creds); // Cropped lifetime. @@ -1252,9 +1252,9 @@ static void test_jwt_creds_lifetime(void) { json_key_string, token_lifetime, nullptr); GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), grpc_max_auth_token_lifetime()) == 0); - GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix))); + GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); grpc_call_credentials_release(jwt_creds); gpr_free(json_key_string); @@ -1298,9 +1298,9 @@ static void test_jwt_creds_success(void) { grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success); run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); - GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, - creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix))); + GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, + creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); creds->Unref(); gpr_free(json_key_string); @@ -1326,9 +1326,9 @@ static void test_jwt_creds_signing_failure(void) { run_request_metadata_test(creds, auth_md_ctx, state); gpr_free(json_key_string); - GPR_ASSERT(!gpr_strincmp(expected_creds_debug_string_prefix, - creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix))); + GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, + creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); creds->Unref(); grpc_jwt_encode_and_sign_set_override(nullptr); @@ -1621,7 +1621,7 @@ static void test_metadata_plugin_success(void) { run_request_metadata_test(creds, auth_md_ctx, md_state); GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); @@ -1655,7 +1655,7 @@ static void test_metadata_plugin_failure(void) { run_request_metadata_test(creds, auth_md_ctx, md_state); GPR_ASSERT(state == PLUGIN_GET_METADATA_CALLED_STATE); GPR_ASSERT( - !gpr_stricmp(creds->debug_string().c_str(), expected_creds_debug_string)); + strcmp(creds->debug_string().c_str(), expected_creds_debug_string) == 0); creds->Unref(); GPR_ASSERT(state == PLUGIN_DESTROY_CALLED_STATE); @@ -1711,8 +1711,8 @@ static void test_channel_creds_duplicate_without_call_creds(void) { grpc_channel_credentials* composite_creds = grpc_composite_channel_credentials_create(channel_creds, call_creds, nullptr); - GPR_ASSERT(!gpr_stricmp(call_creds->debug_string().c_str(), - expected_creds_debug_string)); + GPR_ASSERT(strcmp(call_creds->debug_string().c_str(), + expected_creds_debug_string) == 0); call_creds->Unref(); dup = composite_creds->duplicate_without_call_credentials(); From 4c5ee108da728e41b913c5189428df4eb261aa31 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Wed, 26 Feb 2020 14:14:33 -0800 Subject: [PATCH 3/6] Addressed Yang's comments, I have removed usage of const throughout for consistency --- include/grpcpp/security/credentials_impl.h | 2 +- .../credentials/composite/composite_credentials.cc | 2 +- .../credentials/composite/composite_credentials.h | 4 ++-- src/core/lib/security/credentials/credentials.h | 2 +- .../lib/security/credentials/fake/fake_credentials.h | 4 +--- .../lib/security/credentials/iam/iam_credentials.cc | 11 ++++------- .../lib/security/credentials/iam/iam_credentials.h | 4 ++-- .../lib/security/credentials/jwt/jwt_credentials.h | 2 +- .../security/credentials/oauth2/oauth2_credentials.cc | 10 +++++----- .../security/credentials/oauth2/oauth2_credentials.h | 6 +++--- .../security/credentials/plugin/plugin_credentials.cc | 2 +- .../security/credentials/plugin/plugin_credentials.h | 2 +- test/cpp/end2end/end2end_test.cc | 2 +- 13 files changed, 24 insertions(+), 29 deletions(-) diff --git a/include/grpcpp/security/credentials_impl.h b/include/grpcpp/security/credentials_impl.h index 234ea042da9..aed58283722 100644 --- a/include/grpcpp/security/credentials_impl.h +++ b/include/grpcpp/security/credentials_impl.h @@ -254,7 +254,7 @@ class MetadataCredentialsPlugin { const grpc::AuthContext& channel_auth_context, std::multimap* metadata) = 0; - virtual grpc::string DebugString() const { + virtual grpc::string DebugString() { return "MetadataCredentialsPlugin did not provide a debug string"; } }; diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc index 955e19f2ede..bccc03472e3 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.cc +++ b/src/core/lib/security/credentials/composite/composite_credentials.cc @@ -119,7 +119,7 @@ void grpc_composite_call_credentials::cancel_get_request_metadata( GRPC_ERROR_UNREF(error); } -std::string grpc_composite_call_credentials::debug_string() const { +std::string grpc_composite_call_credentials::debug_string() { std::vector outputs; for (auto& inner_cred : inner_) { outputs.emplace_back(inner_cred->debug_string()); diff --git a/src/core/lib/security/credentials/composite/composite_credentials.h b/src/core/lib/security/credentials/composite/composite_credentials.h index d0f22d75e06..57967e1b6c9 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.h +++ b/src/core/lib/security/credentials/composite/composite_credentials.h @@ -21,7 +21,7 @@ #include -#include +#include #include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -93,7 +93,7 @@ class grpc_composite_call_credentials : public grpc_call_credentials { } const CallCredentialsList& inner() const { return inner_; } - std::string debug_string() const override; + std::string debug_string() override; private: void push_to_inner(grpc_core::RefCountedPtr creds, diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index a7a353ec217..4d1af0588f6 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -254,7 +254,7 @@ struct grpc_call_credentials return min_security_level_; } - virtual std::string debug_string() const { + virtual std::string debug_string() { return "grpc_call_credentials did not provide debug string"; } diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h index a5b87391db9..3c2449fac3e 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.h +++ b/src/core/lib/security/credentials/fake/fake_credentials.h @@ -77,9 +77,7 @@ class grpc_md_only_test_credentials : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; - std::string debug_string() const override { - return "MD only Test Credentials"; - }; + std::string debug_string() override { return "MD only Test Credentials"; }; private: grpc_mdelem md_; diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc index 092a306dfe2..1aeaa888010 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.cc +++ b/src/core/lib/security/credentials/iam/iam_credentials.cc @@ -20,9 +20,6 @@ #include "src/core/lib/security/credentials/iam/iam_credentials.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/surface/api_trace.h" - #include #include #include @@ -51,7 +48,10 @@ void grpc_google_iam_credentials::cancel_get_request_metadata( grpc_google_iam_credentials::grpc_google_iam_credentials( const char* token, const char* authority_selector) - : grpc_call_credentials(GRPC_CALL_CREDENTIALS_TYPE_IAM) { + : grpc_call_credentials(GRPC_CALL_CREDENTIALS_TYPE_IAM), + debug_string_(absl::StrFormat( + "GoogleIAMCredentials{Token:%s,AuthoritySelector:%s}", + token != nullptr ? "present" : "absent", authority_selector)) { grpc_mdelem md = grpc_mdelem_from_slices( grpc_slice_from_static_string(GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY), grpc_slice_from_copied_string(token)); @@ -62,9 +62,6 @@ grpc_google_iam_credentials::grpc_google_iam_credentials( grpc_slice_from_copied_string(authority_selector)); grpc_credentials_mdelem_array_add(&md_array_, md); GRPC_MDELEM_UNREF(md); - debug_string_ = absl::StrFormat( - "GoogleIAMCredentials{Token:%s,AuthoritySelector:%s}", - token != nullptr ? "present" : "absent", authority_selector); } grpc_call_credentials* grpc_google_iam_credentials_create( diff --git a/src/core/lib/security/credentials/iam/iam_credentials.h b/src/core/lib/security/credentials/iam/iam_credentials.h index 3d061a1d395..07139638676 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.h +++ b/src/core/lib/security/credentials/iam/iam_credentials.h @@ -39,11 +39,11 @@ class grpc_google_iam_credentials : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; - std::string debug_string() const override { return debug_string_; } + std::string debug_string() override { return debug_string_; } private: grpc_credentials_mdelem_array md_array_; - std::string debug_string_; + const std::string debug_string_; }; #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h index 16875beb7c4..8ee2665bb4f 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -49,7 +49,7 @@ class grpc_service_account_jwt_access_credentials const gpr_timespec& jwt_lifetime() const { return jwt_lifetime_; } const grpc_auth_json_key& key() const { return key_; } - std::string debug_string() const override { + std::string debug_string() override { return absl::StrFormat("JWTAccessCredentials{ExpirationTime:%s}", absl::FormatTime(absl::FromUnixMicros( gpr_timespec_to_micros(jwt_lifetime_)))); diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 573aec264c7..3a2656496ba 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -357,7 +357,7 @@ grpc_oauth2_token_fetcher_credentials::grpc_oauth2_token_fetcher_credentials() grpc_httpcli_context_init(&httpcli_context_); } -std::string grpc_oauth2_token_fetcher_credentials::debug_string() const { +std::string grpc_oauth2_token_fetcher_credentials::debug_string() { return "OAuth2TokenFetcherCredentials"; } @@ -399,7 +399,7 @@ class grpc_compute_engine_token_fetcher_credentials grpc_resource_quota_unref_internal(resource_quota); } - std::string debug_string() const override { + std::string debug_string() override { return absl::StrFormat( "GoogleComputeEngineTokenFetcherCredentials{%s}", grpc_oauth2_token_fetcher_credentials::debug_string()); @@ -477,7 +477,7 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token( refresh_token); } -std::string grpc_google_refresh_token_credentials::debug_string() const { +std::string grpc_google_refresh_token_credentials::debug_string() { return absl::StrFormat("GoogleRefreshToken{ClientID:%s,%s}", refresh_token_.client_id, grpc_oauth2_token_fetcher_credentials::debug_string()); @@ -555,7 +555,7 @@ class StsTokenFetcherCredentials ~StsTokenFetcherCredentials() override { grpc_uri_destroy(sts_url_); } - std::string debug_string() const override { + std::string debug_string() override { return absl::StrFormat( "StsTokenFetcherCredentials{Path:%s,Authority:%s,%s}", sts_url_->path, sts_url_->authority, @@ -753,7 +753,7 @@ grpc_access_token_credentials::grpc_access_token_credentials( gpr_free(token_md_value); } -std::string grpc_access_token_credentials::debug_string() const { +std::string grpc_access_token_credentials::debug_string() { bool access_token_present = !GRPC_MDISNULL(access_token_md_); return absl::StrFormat("AccessTokenCredentials{Token:%s}", access_token_present ? "present" : "absent"); diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index ee03fa76223..d5f01f13f3e 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -86,7 +86,7 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials { void on_http_response(grpc_credentials_metadata_request* r, grpc_error* error); - std::string debug_string() const override; + std::string debug_string() override; protected: virtual void fetch_oauth2(grpc_credentials_metadata_request* req, @@ -115,7 +115,7 @@ class grpc_google_refresh_token_credentials final return refresh_token_; } - std::string debug_string() const override; + std::string debug_string() override; protected: void fetch_oauth2(grpc_credentials_metadata_request* req, @@ -143,7 +143,7 @@ class grpc_access_token_credentials final : public grpc_call_credentials { void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; - std::string debug_string() const override; + std::string debug_string() override; private: grpc_mdelem access_token_md_; diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 95074947670..3ee05c697f3 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -42,7 +42,7 @@ grpc_plugin_credentials::~grpc_plugin_credentials() { } } -std::string grpc_plugin_credentials::debug_string() const { +std::string grpc_plugin_credentials::debug_string() { std::string debug_str; if (plugin_.debug_string != nullptr) { char* debug_c_str = plugin_.debug_string(plugin_.state); diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h index 413f767d2e3..881eded7643 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.h +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h @@ -59,7 +59,7 @@ struct grpc_plugin_credentials final : public grpc_call_credentials { // cancelled before completion. void pending_request_complete(pending_request* r); - std::string debug_string() const override; + std::string debug_string() override; private: void pending_request_remove_locked(pending_request* pending_request); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 1c20e7da731..665a2605244 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -177,7 +177,7 @@ class TestMetadataCredentialsPlugin : public MetadataCredentialsPlugin { } } - grpc::string DebugString() const override { + grpc::string DebugString() override { return absl::StrFormat("TestMetadataCredentials{key:%s,value:%s}", metadata_key_.c_str(), metadata_value_.c_str()); } From 88b0d84905439f9a4a34e86d655fad2e4e0affeb Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Wed, 26 Feb 2020 18:06:26 -0800 Subject: [PATCH 4/6] Addressed Vijay's comments, fixed string headers --- include/grpc/grpc_security.h | 3 +-- src/core/lib/security/credentials/iam/iam_credentials.h | 2 +- src/core/lib/security/credentials/jwt/jwt_credentials.cc | 1 + src/core/lib/security/credentials/jwt/jwt_credentials.h | 2 +- src/core/lib/security/credentials/oauth2/oauth2_credentials.cc | 2 ++ src/core/lib/security/credentials/oauth2/oauth2_credentials.h | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index e0b8baf489e..bec88ec93cf 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -426,8 +426,7 @@ typedef struct { const char** error_details); /** Implements debug string of the given plugin. This method returns an - * allocated string that the caller needs to free using gpr_free() - * */ + * allocated string that the caller needs to free using gpr_free() */ char* (*debug_string)(void* state); /** Destroys the plugin state. */ diff --git a/src/core/lib/security/credentials/iam/iam_credentials.h b/src/core/lib/security/credentials/iam/iam_credentials.h index 07139638676..9d4a1e2e474 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.h +++ b/src/core/lib/security/credentials/iam/iam_credentials.h @@ -21,7 +21,7 @@ #include -#include +#include #include "src/core/lib/security/credentials/credentials.h" diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc index 6c39ca48dea..bed594e5d92 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc @@ -21,6 +21,7 @@ #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" #include +#include #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h index 8ee2665bb4f..88c0b55598f 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -21,7 +21,7 @@ #include -#include +#include #include diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 3a2656496ba..88b911d6035 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -21,6 +21,8 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" +#include + #include #include #include diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index d5f01f13f3e..9065da4f1d6 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -21,7 +21,7 @@ #include -#include +#include #include #include "src/core/lib/json/json.h" From 38a676ca2e1150d6441492582f2dc8485c4fabc2 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Wed, 26 Feb 2020 20:10:25 -0800 Subject: [PATCH 5/6] Fix abseil version --- third_party/abseil-cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp index 37dd2562ec8..b832dce8489 160000 --- a/third_party/abseil-cpp +++ b/third_party/abseil-cpp @@ -1 +1 @@ -Subproject commit 37dd2562ec830d547a1524bb306be313ac3f2556 +Subproject commit b832dce8489ef7b6231384909fd9b68d5a5ff2b7 From f53456210d1daab6de1313baa29debc42ee6aaff Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Thu, 27 Feb 2020 09:03:52 -0800 Subject: [PATCH 6/6] Addressed Mark's comments --- .../credentials/plugin/plugin_credentials.cc | 17 +++++------ test/core/security/credentials_test.cc | 30 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 3ee05c697f3..ebe59212f82 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -43,17 +43,16 @@ grpc_plugin_credentials::~grpc_plugin_credentials() { } std::string grpc_plugin_credentials::debug_string() { - std::string debug_str; + char* debug_c_str = nullptr; if (plugin_.debug_string != nullptr) { - char* debug_c_str = plugin_.debug_string(plugin_.state); - if (strlen(debug_c_str) != 0) { - debug_str = debug_c_str; - } - gpr_free(debug_c_str); + debug_c_str = plugin_.debug_string(plugin_.state); } - return debug_str.empty() - ? "grpc_plugin_credentials did not provide a debug string" - : debug_str; + std::string debug_str( + debug_c_str != nullptr + ? debug_c_str + : "grpc_plugin_credentials did not provide a debug string"); + gpr_free(debug_c_str); + return debug_str; } void grpc_plugin_credentials::pending_request_remove_locked( diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 3299259d1ee..fd0cf6cc403 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -1228,9 +1228,9 @@ static void test_jwt_creds_lifetime(void) { grpc_max_auth_token_lifetime()) == 0); /* Check security level. */ GPR_ASSERT(jwt_creds->min_security_level() == GRPC_PRIVACY_AND_INTEGRITY); - GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); grpc_call_credentials_release(jwt_creds); // Shorter lifetime. @@ -1240,9 +1240,9 @@ static void test_jwt_creds_lifetime(void) { json_key_string, token_lifetime, nullptr); GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), token_lifetime) == 0); - GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); grpc_call_credentials_release(jwt_creds); // Cropped lifetime. @@ -1252,9 +1252,9 @@ static void test_jwt_creds_lifetime(void) { json_key_string, token_lifetime, nullptr); GPR_ASSERT(gpr_time_cmp(creds_as_jwt(jwt_creds)->jwt_lifetime(), grpc_max_auth_token_lifetime()) == 0); - GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, - jwt_creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, + jwt_creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); grpc_call_credentials_release(jwt_creds); gpr_free(json_key_string); @@ -1298,9 +1298,9 @@ static void test_jwt_creds_success(void) { grpc_jwt_encode_and_sign_set_override(encode_and_sign_jwt_success); run_request_metadata_test(creds, auth_md_ctx, state); grpc_core::ExecCtx::Get()->Flush(); - GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, - creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, + creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); creds->Unref(); gpr_free(json_key_string); @@ -1326,9 +1326,9 @@ static void test_jwt_creds_signing_failure(void) { run_request_metadata_test(creds, auth_md_ctx, state); gpr_free(json_key_string); - GPR_ASSERT(gpr_strincmp(expected_creds_debug_string_prefix, - creds->debug_string().c_str(), - strlen(expected_creds_debug_string_prefix)) == 0); + GPR_ASSERT(strncmp(expected_creds_debug_string_prefix, + creds->debug_string().c_str(), + strlen(expected_creds_debug_string_prefix)) == 0); creds->Unref(); grpc_jwt_encode_and_sign_set_override(nullptr);