grpc 1.83.1 → 1.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +21 -17
  3. data/include/grpc/credentials.h +10 -0
  4. data/include/grpc/grpc_security_constants.h +2 -0
  5. data/include/grpc/impl/channel_arg_names.h +9 -0
  6. data/src/core/call/call_filters.h +4 -2
  7. data/src/core/call/client_call.cc +20 -8
  8. data/src/core/call/client_call.h +4 -0
  9. data/src/core/call/interception_chain.cc +2 -0
  10. data/src/core/call/interception_chain.h +14 -1
  11. data/src/core/call/metadata.cc +1 -3
  12. data/src/core/call/metadata_batch.h +13 -5
  13. data/src/core/call/server_call.cc +31 -14
  14. data/src/core/call/server_call.h +4 -0
  15. data/src/core/channelz/text_encode.cc +9 -4
  16. data/src/core/channelz/v2tov1/convert.cc +2 -2
  17. data/src/core/client_channel/backup_poller.cc +1 -2
  18. data/src/core/client_channel/client_channel.cc +6 -33
  19. data/src/core/client_channel/client_channel_filter.cc +22 -55
  20. data/src/core/client_channel/client_channel_filter.h +2 -2
  21. data/src/core/client_channel/client_channel_service_config.cc +3 -19
  22. data/src/core/client_channel/direct_channel.cc +7 -1
  23. data/src/core/client_channel/direct_channel.h +2 -2
  24. data/src/core/client_channel/load_balanced_call_destination.cc +5 -3
  25. data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -12
  26. data/src/core/client_channel/subchannel.cc +310 -1058
  27. data/src/core/client_channel/subchannel.h +44 -329
  28. data/src/core/client_channel/subchannel_metrics.cc +48 -0
  29. data/src/core/client_channel/subchannel_metrics.h +60 -0
  30. data/src/core/credentials/call/external/file_external_account_credentials.cc +1 -1
  31. data/src/core/credentials/call/external/url_external_account_credentials.cc +2 -3
  32. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +8 -24
  33. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h +3 -6
  34. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.cc +525 -0
  35. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.h +138 -0
  36. data/src/core/credentials/call/json_util.h +1 -0
  37. data/src/core/credentials/call/jwt/json_token.cc +10 -2
  38. data/src/core/credentials/call/jwt/jwt_verifier.cc +15 -1
  39. data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +1 -1
  40. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +42 -79
  41. data/src/core/credentials/call/oauth2/oauth2_credentials.h +2 -5
  42. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +52 -31
  43. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h +21 -8
  44. data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -4
  45. data/src/core/credentials/transport/ssl/ssl_credentials.cc +59 -72
  46. data/src/core/credentials/transport/ssl/ssl_credentials.h +9 -8
  47. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +12 -6
  48. data/src/core/credentials/transport/ssl/ssl_security_connector.h +4 -4
  49. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -18
  50. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +9 -6
  51. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +45 -56
  52. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +5 -4
  53. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +26 -0
  54. data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +1 -1
  55. data/src/core/credentials/transport/tls/load_system_roots.h +2 -6
  56. data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +2 -4
  57. data/src/core/credentials/transport/tls/load_system_roots_supported.cc +13 -15
  58. data/src/core/credentials/transport/tls/load_system_roots_supported.h +3 -2
  59. data/src/core/credentials/transport/tls/load_system_roots_windows.cc +5 -8
  60. data/src/core/credentials/transport/tls/spiffe_utils.cc +1 -1
  61. data/src/core/credentials/transport/tls/ssl_utils.cc +39 -28
  62. data/src/core/credentials/transport/tls/ssl_utils.h +12 -49
  63. data/src/core/credentials/transport/tls/tls_security_connector.cc +48 -33
  64. data/src/core/credentials/transport/tls/tls_security_connector.h +31 -10
  65. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +15 -11
  66. data/src/core/ext/filters/http/http_filters_plugin.cc +20 -9
  67. data/src/core/ext/filters/rbac/rbac_filter.cc +43 -21
  68. data/src/core/ext/filters/rbac/rbac_filter.h +21 -3
  69. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -2
  70. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
  71. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -20
  72. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +32 -67
  73. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
  74. data/src/core/ext/transport/chttp2/transport/flow_control.h +78 -4
  75. data/src/core/ext/transport/chttp2/transport/frame.h +2 -0
  76. data/src/core/ext/transport/chttp2/transport/frame_data.cc +3 -4
  77. data/src/core/ext/transport/chttp2/transport/goaway.h +7 -0
  78. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +5 -3
  79. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -1
  80. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +141 -130
  81. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +22 -22
  82. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +402 -269
  83. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +80 -49
  84. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +1 -2
  85. data/src/core/ext/transport/chttp2/transport/http2_status.h +38 -37
  86. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +178 -5
  87. data/src/core/ext/transport/chttp2/transport/http2_transport.h +345 -5
  88. data/src/core/ext/transport/chttp2/transport/parsing.cc +5 -5
  89. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +3 -2
  90. data/src/core/ext/transport/chttp2/transport/ping_promise.h +25 -5
  91. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +3 -4
  92. data/src/core/ext/transport/chttp2/transport/read_context.h +30 -3
  93. data/src/core/ext/transport/chttp2/transport/stream.h +65 -23
  94. data/src/core/ext/transport/chttp2/transport/writing.cc +0 -3
  95. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -5
  96. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +4 -17
  97. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +1912 -0
  98. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +300 -0
  99. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.h +37 -0
  100. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb.h +187 -0
  101. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.c +64 -0
  102. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.h +31 -0
  103. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +2362 -0
  104. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +556 -0
  105. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +47 -0
  106. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb.h +5 -5
  107. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.c +3 -3
  108. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.h +5 -5
  109. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +453 -0
  110. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.h +67 -0
  111. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.c +142 -0
  112. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.h +37 -0
  113. data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +715 -0
  114. data/src/core/ext/upbdefs-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upbdefs.h +44 -44
  115. data/src/core/filter/auth/server_auth_filter.cc +2 -3
  116. data/src/core/filter/composite/composite_filter.cc +45 -33
  117. data/src/core/filter/composite/composite_filter.h +5 -4
  118. data/src/core/filter/ext_proc/ext_proc_filter.cc +224 -0
  119. data/src/core/filter/ext_proc/ext_proc_filter.h +155 -0
  120. data/src/core/filter/ext_proc/ext_proc_messages.cc +701 -0
  121. data/src/core/filter/ext_proc/ext_proc_messages.h +297 -0
  122. data/src/core/filter/filter_args.h +13 -2
  123. data/src/core/handshaker/http_connect/http_proxy_mapper.cc +30 -3
  124. data/src/core/handshaker/security/security_handshaker.cc +9 -6
  125. data/src/core/lib/channel/channel_stack.cc +3 -0
  126. data/src/core/lib/channel/channel_stack.h +2 -0
  127. data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -2
  128. data/src/core/lib/channel/promise_based_filter.cc +132 -20
  129. data/src/core/lib/channel/promise_based_filter.h +42 -12
  130. data/src/core/lib/compression/compression_internal.cc +4 -5
  131. data/src/core/lib/debug/trace_flags.cc +8 -0
  132. data/src/core/lib/debug/trace_flags.h +3 -0
  133. data/src/core/lib/event_engine/ares_resolver.cc +54 -50
  134. data/src/core/lib/event_engine/ares_resolver.h +3 -2
  135. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +3 -3
  136. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -10
  137. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +74 -33
  138. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +4 -4
  139. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +6 -2
  140. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -0
  141. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +3 -0
  142. data/src/core/lib/event_engine/windows/windows_endpoint.cc +1 -3
  143. data/src/core/lib/experiments/experiments.cc +60 -96
  144. data/src/core/lib/experiments/experiments.h +34 -50
  145. data/src/core/lib/iomgr/cfstream_handle.cc +2 -6
  146. data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -10
  147. data/src/core/lib/iomgr/error.cc +2 -6
  148. data/src/core/lib/iomgr/error_cfstream.cc +1 -1
  149. data/src/core/lib/iomgr/ev_poll_posix.cc +5 -9
  150. data/src/core/lib/iomgr/event_engine_shims/closure.cc +1 -1
  151. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +1 -2
  152. data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +1 -2
  153. data/src/core/lib/iomgr/iomgr_posix.cc +0 -4
  154. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +0 -4
  155. data/src/core/lib/iomgr/iomgr_windows.cc +0 -4
  156. data/src/core/lib/iomgr/socket_factory_posix.h +1 -1
  157. data/src/core/lib/iomgr/socket_utils_posix.cc +3 -0
  158. data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
  159. data/src/core/lib/iomgr/systemd_utils.cc +0 -1
  160. data/src/core/lib/iomgr/tcp_client.h +1 -1
  161. data/src/core/lib/iomgr/tcp_posix.cc +23 -15
  162. data/src/core/lib/iomgr/tcp_server.h +1 -1
  163. data/src/core/lib/iomgr/tcp_server_posix.cc +2 -3
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -1
  165. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -1
  166. data/src/core/lib/iomgr/tcp_windows.cc +5 -10
  167. data/src/core/lib/iomgr/unix_sockets_posix.cc +2 -4
  168. data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
  169. data/src/core/lib/iomgr/vsock.h +3 -1
  170. data/src/core/lib/resource_quota/memory_quota.cc +1 -1
  171. data/src/core/lib/security/authorization/rbac_policy.cc +139 -56
  172. data/src/core/lib/security/authorization/rbac_policy.h +21 -3
  173. data/src/core/lib/surface/call.cc +3 -9
  174. data/src/core/lib/surface/call_utils.h +113 -0
  175. data/src/core/lib/surface/channel_create.cc +1 -1
  176. data/src/core/lib/surface/channel_create.h +0 -2
  177. data/src/core/lib/surface/channel_init.cc +77 -38
  178. data/src/core/lib/surface/channel_init.h +30 -16
  179. data/src/core/lib/surface/filter_stack_call.cc +5 -10
  180. data/src/core/lib/surface/init.cc +13 -27
  181. data/src/core/lib/surface/version.cc +1 -1
  182. data/src/core/lib/transport/error_utils.cc +0 -27
  183. data/src/core/lib/transport/error_utils.h +0 -16
  184. data/src/core/lib/transport/transport.h +7 -5
  185. data/src/core/load_balancing/pick_first/pick_first.cc +2 -0
  186. data/src/core/load_balancing/rls/rls.cc +28 -11
  187. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +33 -42
  188. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.h +0 -2
  189. data/src/core/load_balancing/xds/cds.cc +3 -1
  190. data/src/core/load_balancing/xds/xds_cluster_impl.cc +0 -1
  191. data/src/core/mitigation_engine/mitigation.h +14 -5
  192. data/src/core/mitigation_engine/mitigation_engine.h +7 -3
  193. data/src/core/mitigation_engine/mitigation_provider.h +2 -1
  194. data/src/core/plugin_registry/grpc_plugin_registry.cc +39 -8
  195. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.cc → dns_resolver.cc} +42 -41
  196. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.h → dns_resolver.h} +8 -5
  197. data/src/core/resolver/dns/{event_engine/service_config_helper.cc → service_config_helper.cc} +1 -1
  198. data/src/core/resolver/dns/{event_engine/service_config_helper.h → service_config_helper.h} +3 -3
  199. data/src/core/resolver/endpoint_addresses.h +3 -0
  200. data/src/core/resolver/google_c2p/google_c2p_resolver.cc +2 -1
  201. data/src/core/resolver/xds/xds_resolver.cc +35 -9
  202. data/src/core/server/server.cc +2 -6
  203. data/src/core/server/server_config_selector.h +18 -3
  204. data/src/core/server/server_config_selector_filter.cc +178 -91
  205. data/src/core/server/server_config_selector_filter.h +58 -3
  206. data/src/core/server/xds_server_config_fetcher.cc +196 -129
  207. data/src/core/server/xds_server_config_fetcher.h +49 -0
  208. data/src/core/server/xds_server_config_fetcher_legacy.cc +41 -37
  209. data/src/core/telemetry/histogram.h +94 -14
  210. data/src/core/telemetry/instrument.cc +179 -74
  211. data/src/core/telemetry/instrument.h +78 -30
  212. data/src/core/telemetry/metrics.h +5 -0
  213. data/src/core/{resolver/dns/dns_resolver_plugin.h → telemetry/telemetry_label.h} +12 -8
  214. data/src/core/tsi/alts/crypt/aes_gcm.cc +10 -13
  215. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -2
  216. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +3 -1
  217. data/src/core/tsi/ssl_telemetry_utils.cc +216 -259
  218. data/src/core/tsi/ssl_telemetry_utils.h +12 -2
  219. data/src/core/tsi/ssl_transport_security.cc +238 -80
  220. data/src/core/tsi/ssl_transport_security.h +63 -33
  221. data/src/core/tsi/tls_telemetry.cc +31 -0
  222. data/src/core/tsi/tls_telemetry.h +47 -0
  223. data/src/core/tsi/transport_security.cc +2 -2
  224. data/src/core/tsi/transport_security.h +1 -1
  225. data/src/core/tsi/transport_security_interface.h +1 -1
  226. data/src/core/{resolver/dns/native/dns_resolver.h → util/address_sorting_init.cc} +21 -8
  227. data/src/core/{resolver/dns/c_ares/grpc_ares_wrapper_posix.cc → util/address_sorting_init.h} +7 -8
  228. data/src/core/util/http_client/httpcli.cc +16 -53
  229. data/src/core/util/http_client/httpcli.h +0 -7
  230. data/src/core/util/http_client/httpcli_security_connector.cc +13 -8
  231. data/src/core/util/linux/cpu.cc +1 -1
  232. data/src/core/util/load_file.cc +3 -9
  233. data/src/core/util/load_file.h +3 -4
  234. data/src/core/util/matchers.h +8 -0
  235. data/src/core/util/posix/cpu.cc +1 -1
  236. data/src/core/util/status_helper.cc +0 -20
  237. data/src/core/util/status_helper.h +3 -14
  238. data/src/core/xds/grpc/xds_audit_logger_registry.cc +51 -31
  239. data/src/core/xds/grpc/xds_audit_logger_registry.h +17 -3
  240. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -10
  241. data/src/core/xds/grpc/xds_bootstrap_grpc.h +8 -6
  242. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +488 -0
  243. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +97 -0
  244. data/src/core/xds/grpc/xds_certificate_provider.cc +7 -7
  245. data/src/core/xds/grpc/xds_client_grpc.cc +4 -8
  246. data/src/core/xds/grpc/xds_client_grpc.h +0 -4
  247. data/src/core/xds/grpc/xds_cluster.h +1 -0
  248. data/src/core/xds/grpc/xds_cluster_parser.cc +1 -5
  249. data/src/core/xds/grpc/xds_cluster_parser.h +0 -2
  250. data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +0 -2
  251. data/src/core/xds/grpc/xds_cluster_specifier_plugin.h +0 -2
  252. data/src/core/xds/grpc/xds_common_types.cc +0 -91
  253. data/src/core/xds/grpc/xds_common_types.h +1 -47
  254. data/src/core/xds/grpc/xds_common_types_parser.cc +84 -378
  255. data/src/core/xds/grpc/xds_common_types_parser.h +9 -11
  256. data/src/core/xds/grpc/xds_endpoint_parser.cc +0 -2
  257. data/src/core/xds/grpc/xds_grpc_service_parser.cc +177 -0
  258. data/src/core/{resolver/dns/c_ares/dns_resolver_ares.h → xds/grpc/xds_grpc_service_parser.h} +14 -9
  259. data/src/core/xds/grpc/xds_http_composite_filter.cc +26 -21
  260. data/src/core/xds/grpc/xds_http_composite_filter.h +4 -3
  261. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +418 -0
  262. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +89 -0
  263. data/src/core/xds/grpc/xds_http_fault_filter.cc +9 -12
  264. data/src/core/xds/grpc/xds_http_fault_filter.h +1 -4
  265. data/src/core/xds/grpc/xds_http_filter.cc +2 -1
  266. data/src/core/xds/grpc/xds_http_filter.h +6 -5
  267. data/src/core/xds/grpc/xds_http_filter_registry.cc +10 -127
  268. data/src/core/xds/grpc/xds_http_filter_registry.h +7 -59
  269. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +13 -14
  270. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -2
  271. data/src/core/xds/grpc/xds_http_rbac_filter.cc +403 -25
  272. data/src/core/xds/grpc/xds_http_rbac_filter.h +1 -3
  273. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +8 -13
  274. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +1 -4
  275. data/src/core/xds/grpc/xds_lb_policy_registry.cc +0 -292
  276. data/src/core/xds/grpc/xds_lb_policy_registry.h +7 -3
  277. data/src/core/xds/grpc/xds_listener.cc +2 -0
  278. data/src/core/xds/grpc/xds_listener.h +5 -0
  279. data/src/core/xds/grpc/xds_listener_parser.cc +16 -11
  280. data/src/core/xds/grpc/xds_matcher_parse.h +3 -1
  281. data/src/core/xds/grpc/xds_metadata_parser.cc +6 -1
  282. data/src/core/xds/grpc/xds_metadata_parser.h +2 -0
  283. data/src/core/xds/grpc/xds_route_config.cc +2 -0
  284. data/src/core/xds/grpc/xds_route_config.h +3 -1
  285. data/src/core/xds/grpc/xds_route_config_parser.cc +13 -79
  286. data/src/core/xds/grpc/xds_route_config_parser.h +0 -3
  287. data/src/core/xds/grpc/xds_routing.cc +116 -69
  288. data/src/core/xds/grpc/xds_routing.h +19 -8
  289. data/src/core/xds/grpc/xds_tls_context.cc +117 -0
  290. data/src/core/xds/grpc/xds_tls_context.h +76 -0
  291. data/src/core/xds/grpc/xds_tls_context_parser.cc +275 -0
  292. data/src/core/xds/grpc/xds_tls_context_parser.h +35 -0
  293. data/src/core/xds/grpc/xds_transport_grpc.cc +41 -38
  294. data/src/core/xds/grpc/xds_transport_grpc.h +4 -2
  295. data/src/ruby/ext/grpc/rb_call.c +26 -15
  296. data/src/ruby/ext/grpc/rb_completion_queue.c +6 -5
  297. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  298. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  299. data/src/ruby/lib/grpc/version.rb +1 -1
  300. data/src/ruby/pb/test/client.rb +5 -4
  301. data/src/ruby/spec/call_spec.rb +14 -0
  302. data/src/ruby/spec/generic/server_interceptors_spec.rb +3 -6
  303. metadata +50 -35
  304. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +0 -716
  305. data/src/core/lib/iomgr/resolve_address.cc +0 -59
  306. data/src/core/lib/iomgr/resolve_address.h +0 -125
  307. data/src/core/lib/iomgr/resolve_address_impl.h +0 -58
  308. data/src/core/lib/iomgr/resolve_address_posix.cc +0 -184
  309. data/src/core/lib/iomgr/resolve_address_posix.h +0 -78
  310. data/src/core/lib/iomgr/resolve_address_windows.cc +0 -169
  311. data/src/core/lib/iomgr/resolve_address_windows.h +0 -76
  312. data/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +0 -781
  313. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +0 -93
  314. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +0 -203
  315. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +0 -838
  316. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +0 -1237
  317. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +0 -130
  318. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -35
  319. data/src/core/resolver/dns/dns_resolver_plugin.cc +0 -64
  320. data/src/core/resolver/dns/native/dns_resolver.cc +0 -173
  321. data/src/core/util/json/json_util.cc +0 -101
  322. data/src/core/util/json/json_util.h +0 -163
@@ -34,6 +34,7 @@
34
34
  #include <vector>
35
35
 
36
36
  #include "src/core/credentials/transport/security_connector.h"
37
+ #include "src/core/credentials/transport/tls/grpc_tls_certificate_selector.h"
37
38
  #include "src/core/credentials/transport/tls/spiffe_utils.h"
38
39
  #include "src/core/lib/iomgr/error.h"
39
40
  #include "src/core/tsi/ssl/key_logging/ssl_key_logging.h"
@@ -88,7 +89,7 @@ const char** ParseAlpnStringIntoArray(absl::string_view preferred_protocols,
88
89
 
89
90
  // Initialize TSI SSL server/client handshaker factory.
90
91
  grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
91
- tsi_ssl_pem_key_cert_pair* key_cert_pair,
92
+ const grpc_core::PemKeyCertPair* key_cert_pair,
92
93
  std::shared_ptr<tsi::RootCertInfo> root_cert_info,
93
94
  bool skip_server_certificate_verification, tsi_tls_version min_tls_version,
94
95
  tsi_tls_version max_tls_version, tsi_ssl_session_cache* ssl_session_cache,
@@ -99,7 +100,7 @@ grpc_security_status grpc_ssl_tsi_client_handshaker_factory_init(
99
100
  tsi_ssl_client_handshaker_factory** handshaker_factory);
100
101
 
101
102
  grpc_security_status grpc_ssl_tsi_server_handshaker_factory_init(
102
- std::vector<tsi_ssl_pem_key_cert_pair> key_cert_pairs,
103
+ grpc_core::KeyCertPairsOrSelector key_cert_pairs,
103
104
  std::shared_ptr<tsi::RootCertInfo> root_cert_info,
104
105
  grpc_ssl_client_certificate_request_type client_certificate_request,
105
106
  tsi_tls_version min_tls_version, tsi_tls_version max_tls_version,
@@ -120,8 +121,6 @@ int grpc_ssl_host_matches_name(const tsi_peer* peer,
120
121
 
121
122
  // --- Default SSL Root Store. ---
122
123
  namespace grpc_core {
123
- using tsi::PrivateKey;
124
-
125
124
  bool IsPrivateKeyEmpty(const PrivateKey& private_key);
126
125
 
127
126
  // The class implements default SSL root store.
@@ -131,12 +130,11 @@ class DefaultSslRootStore {
131
130
  static const tsi_ssl_root_certs_store* GetRootStore();
132
131
 
133
132
  // Gets the default PEM root certificate.
134
- static const char* GetPemRootCerts();
133
+ static absl::string_view GetPemRootCerts();
135
134
 
136
- protected:
137
- // Returns default PEM root certificates in nullptr terminated grpc_slice.
138
- // This function is protected instead of private, so that it can be tested.
139
- static grpc_slice ComputePemRootCerts();
135
+ // Returns default PEM root certificates.
136
+ // DO NOT USE -- exposed for testing purposes only.
137
+ static Slice ComputePemRootCerts();
140
138
 
141
139
  private:
142
140
  // Construct me not!
@@ -152,48 +150,13 @@ class DefaultSslRootStore {
152
150
  static tsi_ssl_root_certs_store* default_root_store_;
153
151
 
154
152
  // Default PEM root certificates.
155
- static grpc_slice default_pem_root_certs_;
156
- };
157
-
158
- class PemKeyCertPair {
159
- public:
160
- PemKeyCertPair(PrivateKey private_key, absl::string_view cert_chain)
161
- : private_key_(std::move(private_key)), cert_chain_(cert_chain) {}
162
-
163
- // Movable.
164
- PemKeyCertPair(PemKeyCertPair&& other) noexcept {
165
- private_key_ = std::move(other.private_key_);
166
- cert_chain_ = std::move(other.cert_chain_);
167
- }
168
- PemKeyCertPair& operator=(PemKeyCertPair&& other) noexcept {
169
- private_key_ = std::move(other.private_key_);
170
- cert_chain_ = std::move(other.cert_chain_);
171
- return *this;
172
- }
173
-
174
- // Copyable.
175
- PemKeyCertPair(const PemKeyCertPair& other)
176
- : private_key_(other.private_key()), cert_chain_(other.cert_chain()) {}
177
- PemKeyCertPair& operator=(const PemKeyCertPair& other) {
178
- private_key_ = other.private_key();
179
- cert_chain_ = other.cert_chain();
180
- return *this;
181
- }
182
-
183
- bool operator==(const PemKeyCertPair& other) const {
184
- return this->private_key() == other.private_key() &&
185
- this->cert_chain() == other.cert_chain();
186
- }
187
-
188
- const PrivateKey& private_key() const { return private_key_; }
189
- const std::string& cert_chain() const { return cert_chain_; }
190
-
191
- private:
192
- PrivateKey private_key_;
193
- std::string cert_chain_;
153
+ static Slice default_pem_root_certs_;
194
154
  };
195
155
 
196
- using PemKeyCertPairList = std::vector<PemKeyCertPair>;
156
+ // Checks whether `std::vector<PemKeyCertPair>` in the variant is empty, or the
157
+ // `CertficateSelector` is nullptr.
158
+ bool IsKeyCertPairsOrSelectorEmpty(
159
+ const KeyCertPairsOrSelector& key_cert_pairs_or_selector);
197
160
 
198
161
  } // namespace grpc_core
199
162
 
@@ -31,6 +31,8 @@
31
31
  #include <utility>
32
32
  #include <vector>
33
33
 
34
+ #include "src/core/client_channel/client_channel_args.h"
35
+ #include "src/core/credentials/transport/tls/grpc_tls_certificate_selector.h"
34
36
  #include "src/core/credentials/transport/tls/grpc_tls_certificate_verifier.h"
35
37
  #include "src/core/credentials/transport/tls/grpc_tls_credentials_options.h"
36
38
  #include "src/core/credentials/transport/tls/ssl_utils.h"
@@ -75,6 +77,7 @@ void PendingVerifierRequestInit(
75
77
  bool has_peer_cert = false;
76
78
  bool has_peer_cert_full_chain = false;
77
79
  bool has_verified_root_cert_subject = false;
80
+ bool has_negotiated_key_exchange_group = false;
78
81
  std::vector<char*> uri_names;
79
82
  std::vector<char*> dns_names;
80
83
  std::vector<char*> email_names;
@@ -111,6 +114,10 @@ void PendingVerifierRequestInit(
111
114
  request->peer_info.verified_root_cert_subject =
112
115
  CopyCoreString(prop->value.data, prop->value.length);
113
116
  has_verified_root_cert_subject = true;
117
+ } else if (strcmp(prop->name, TSI_SSL_NEGOTIATED_KEY_EXCHANGE_GROUP) == 0) {
118
+ request->peer_info.negotiated_key_exchange_group =
119
+ CopyCoreString(prop->value.data, prop->value.length);
120
+ has_negotiated_key_exchange_group = true;
114
121
  }
115
122
  }
116
123
  if (!has_common_name) {
@@ -125,6 +132,9 @@ void PendingVerifierRequestInit(
125
132
  if (!has_verified_root_cert_subject) {
126
133
  request->peer_info.verified_root_cert_subject = nullptr;
127
134
  }
135
+ if (!has_negotiated_key_exchange_group) {
136
+ request->peer_info.negotiated_key_exchange_group = nullptr;
137
+ }
128
138
  request->peer_info.san_names.uri_names_size = uri_names.size();
129
139
  if (!uri_names.empty()) {
130
140
  request->peer_info.san_names.uri_names =
@@ -214,20 +224,11 @@ void PendingVerifierRequestDestroy(
214
224
  if (request->peer_info.verified_root_cert_subject != nullptr) {
215
225
  gpr_free(const_cast<char*>(request->peer_info.verified_root_cert_subject));
216
226
  }
217
- }
218
-
219
- std::vector<tsi_ssl_pem_key_cert_pair> ConvertToTsiPemKeyCertPair(
220
- const PemKeyCertPairList& cert_pair_list) {
221
- std::vector<tsi_ssl_pem_key_cert_pair> tsi_pairs;
222
- for (size_t i = 0; i < cert_pair_list.size(); i++) {
223
- GRPC_CHECK(!IsPrivateKeyEmpty(cert_pair_list[i].private_key()));
224
- GRPC_CHECK(!cert_pair_list[i].cert_chain().empty());
225
- tsi_pairs.emplace_back(cert_pair_list[i].private_key(),
226
- cert_pair_list[i].cert_chain());
227
+ if (request->peer_info.negotiated_key_exchange_group != nullptr) {
228
+ gpr_free(
229
+ const_cast<char*>(request->peer_info.negotiated_key_exchange_group));
227
230
  }
228
- return tsi_pairs;
229
231
  }
230
-
231
232
  } // namespace
232
233
 
233
234
  // -------------------channel security connector-------------------
@@ -369,12 +370,17 @@ void TlsChannelSecurityConnector::add_handshakers(
369
370
  RefCountedPtr<CollectionScope> collection_scope =
370
371
  stats_plugin_group != nullptr ? stats_plugin_group->GetCollectionScope()
371
372
  : nullptr;
373
+ std::string backend_service(
374
+ args.GetString(GRPC_ARG_BACKEND_SERVICE).value_or(""));
375
+ std::string locality(args.GetString(GRPC_ARG_LB_LOCALITY).value_or(""));
376
+ std::string target(args.GetString(GRPC_ARG_SERVER_URI).value_or(""));
372
377
  tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
373
378
  client_handshaker_factory_, server_name_indication,
374
379
  /*network_bio_buf_size=*/0,
375
380
  /*ssl_bio_buf_size=*/0,
376
381
  args.GetOwnedString(GRPC_ARG_TRANSPORT_PROTOCOLS),
377
- std::move(collection_scope), &tsi_hs);
382
+ std::move(collection_scope), std::move(target), std::move(locality),
383
+ std::move(backend_service), &tsi_hs);
378
384
  if (result != TSI_OK) {
379
385
  LOG(ERROR) << "Handshaker creation failed with error "
380
386
  << tsi_result_to_string(result);
@@ -455,15 +461,17 @@ ArenaPromise<absl::Status> TlsChannelSecurityConnector::CheckCallHost(
455
461
  }
456
462
 
457
463
  void TlsChannelSecurityConnector::TlsChannelCertificateWatcher::
458
- OnCertificatesChanged(std::shared_ptr<tsi::RootCertInfo> root_certs,
459
- std::optional<PemKeyCertPairList> key_cert_pairs) {
464
+ OnCertificatesChanged(
465
+ std::shared_ptr<tsi::RootCertInfo> root_certs,
466
+ std::optional<KeyCertPairsOrSelector> key_cert_pairs_or_selector) {
460
467
  GRPC_CHECK_NE(security_connector_, nullptr);
461
468
  MutexLock lock(&security_connector_->mu_);
462
469
  if (root_certs != nullptr) {
463
470
  security_connector_->root_cert_info_ = std::move(root_certs);
464
471
  }
465
- if (key_cert_pairs.has_value()) {
466
- security_connector_->pem_key_cert_pair_list_ = std::move(key_cert_pairs);
472
+ if (key_cert_pairs_or_selector.has_value()) {
473
+ security_connector_->key_cert_pairs_or_selector_ =
474
+ std::move(key_cert_pairs_or_selector);
467
475
  }
468
476
  const bool root_ready =
469
477
  security_connector_->options_->root_certificate_distributor() ==
@@ -472,7 +480,7 @@ void TlsChannelSecurityConnector::TlsChannelCertificateWatcher::
472
480
  const bool identity_ready =
473
481
  security_connector_->options_->identity_certificate_distributor() ==
474
482
  nullptr ||
475
- security_connector_->pem_key_cert_pair_list_.has_value();
483
+ security_connector_->key_cert_pairs_or_selector_.has_value();
476
484
  if (root_ready && identity_ready) {
477
485
  if (security_connector_->UpdateHandshakerFactoryLocked() !=
478
486
  GRPC_SECURITY_OK) {
@@ -554,14 +562,20 @@ TlsChannelSecurityConnector::UpdateHandshakerFactoryLocked() {
554
562
  if (client_handshaker_factory_ != nullptr) {
555
563
  tsi_ssl_client_handshaker_factory_unref(client_handshaker_factory_);
556
564
  }
557
- std::vector<tsi_ssl_pem_key_cert_pair> pem_key_cert_pair;
558
- if (pem_key_cert_pair_list_.has_value()) {
559
- pem_key_cert_pair = ConvertToTsiPemKeyCertPair(*pem_key_cert_pair_list_);
565
+ const PemKeyCertPair* pem_key_cert_pair = nullptr;
566
+ if (key_cert_pairs_or_selector_.has_value()) {
567
+ Match(
568
+ *key_cert_pairs_or_selector_,
569
+ [&pem_key_cert_pair](const PemKeyCertPairList& pem_key_cert_pairs) {
570
+ pem_key_cert_pair =
571
+ pem_key_cert_pairs.empty() ? nullptr : &pem_key_cert_pairs[0];
572
+ },
573
+ // This is not expected to happen and we do nothing here.
574
+ [](const std::shared_ptr<CertificateSelector>&) {});
560
575
  }
561
576
  bool use_default_roots = options_->root_certificate_distributor() == nullptr;
562
577
  return grpc_ssl_tsi_client_handshaker_factory_init(
563
- pem_key_cert_pair.empty() ? nullptr : &pem_key_cert_pair[0],
564
- use_default_roots ? nullptr : root_cert_info_,
578
+ pem_key_cert_pair, use_default_roots ? nullptr : root_cert_info_,
565
579
  skip_server_certificate_verification,
566
580
  grpc_get_tsi_tls_version(options_->min_tls_version()),
567
581
  grpc_get_tsi_tls_version(options_->max_tls_version()), ssl_session_cache_,
@@ -730,15 +744,17 @@ int TlsServerSecurityConnector::cmp(
730
744
  }
731
745
 
732
746
  void TlsServerSecurityConnector::TlsServerCertificateWatcher::
733
- OnCertificatesChanged(std::shared_ptr<tsi::RootCertInfo> roots,
734
- std::optional<PemKeyCertPairList> key_cert_pairs) {
747
+ OnCertificatesChanged(
748
+ std::shared_ptr<tsi::RootCertInfo> roots,
749
+ std::optional<KeyCertPairsOrSelector> key_cert_pairs_or_selector) {
735
750
  GRPC_CHECK_NE(security_connector_, nullptr);
736
751
  MutexLock lock(&security_connector_->mu_);
737
752
  if (roots != nullptr) {
738
753
  security_connector_->root_cert_info_ = std::move(roots);
739
754
  }
740
- if (key_cert_pairs.has_value()) {
741
- security_connector_->pem_key_cert_pair_list_ = std::move(key_cert_pairs);
755
+ if (key_cert_pairs_or_selector.has_value()) {
756
+ security_connector_->key_cert_pairs_or_selector_ =
757
+ std::move(key_cert_pairs_or_selector);
742
758
  }
743
759
  bool root_being_watched =
744
760
  security_connector_->options_->root_certificate_distributor() != nullptr;
@@ -747,7 +763,7 @@ void TlsServerSecurityConnector::TlsServerCertificateWatcher::
747
763
  security_connector_->options_->identity_certificate_distributor() !=
748
764
  nullptr;
749
765
  bool identity_has_value =
750
- security_connector_->pem_key_cert_pair_list_.has_value();
766
+ security_connector_->key_cert_pairs_or_selector_.has_value();
751
767
  if ((root_being_watched && root_has_value && identity_being_watched &&
752
768
  identity_has_value) ||
753
769
  (root_being_watched && root_has_value && !identity_being_watched) ||
@@ -831,12 +847,11 @@ TlsServerSecurityConnector::UpdateHandshakerFactoryLocked() {
831
847
  tsi_ssl_server_handshaker_factory_unref(server_handshaker_factory_);
832
848
  }
833
849
  // The identity certs on the server side shouldn't be empty.
834
- GRPC_CHECK(pem_key_cert_pair_list_.has_value());
835
- GRPC_CHECK(!(*pem_key_cert_pair_list_).empty());
836
- std::vector<tsi_ssl_pem_key_cert_pair> pem_key_cert_pairs =
837
- ConvertToTsiPemKeyCertPair(*pem_key_cert_pair_list_);
850
+ GRPC_CHECK(key_cert_pairs_or_selector_.has_value());
851
+ GRPC_CHECK(!IsKeyCertPairsOrSelectorEmpty(*key_cert_pairs_or_selector_));
838
852
  return grpc_ssl_tsi_server_handshaker_factory_init(
839
- pem_key_cert_pairs, root_cert_info_, options_->cert_request_type(),
853
+ *key_cert_pairs_or_selector_, root_cert_info_,
854
+ options_->cert_request_type(),
840
855
  grpc_get_tsi_tls_version(options_->min_tls_version()),
841
856
  grpc_get_tsi_tls_version(options_->max_tls_version()),
842
857
  tls_session_key_logger_.get(), options_->crl_directory().c_str(),
@@ -25,11 +25,13 @@
25
25
  #include <grpc/support/port_platform.h>
26
26
 
27
27
  #include <map>
28
+ #include <memory>
28
29
  #include <optional>
29
30
  #include <string>
30
31
 
31
32
  #include "src/core/credentials/transport/security_connector.h"
32
33
  #include "src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h"
34
+ #include "src/core/credentials/transport/tls/grpc_tls_certificate_selector.h"
33
35
  #include "src/core/credentials/transport/tls/ssl_utils.h"
34
36
  #include "src/core/handshaker/handshaker.h"
35
37
  #include "src/core/lib/channel/channel_args.h"
@@ -41,6 +43,7 @@
41
43
  #include "src/core/tsi/ssl/key_logging/ssl_key_logging.h"
42
44
  #include "src/core/tsi/ssl_transport_security.h"
43
45
  #include "src/core/tsi/transport_security_interface.h"
46
+ #include "src/core/util/match.h"
44
47
  #include "src/core/util/ref_counted_ptr.h"
45
48
  #include "src/core/util/sync.h"
46
49
  #include "absl/base/thread_annotations.h"
@@ -96,7 +99,16 @@ class TlsChannelSecurityConnector final
96
99
 
97
100
  std::optional<PemKeyCertPairList> KeyCertPairListForTesting() {
98
101
  MutexLock lock(&mu_);
99
- return pem_key_cert_pair_list_;
102
+ std::optional<PemKeyCertPairList> pem_key_cert_pairs;
103
+ if (key_cert_pairs_or_selector_.has_value()) {
104
+ Match(
105
+ *key_cert_pairs_or_selector_,
106
+ [&pem_key_cert_pairs](const PemKeyCertPairList& key_cert_pairs) {
107
+ pem_key_cert_pairs = key_cert_pairs;
108
+ },
109
+ [](const std::shared_ptr<CertificateSelector>&) {});
110
+ }
111
+ return pem_key_cert_pairs;
100
112
  }
101
113
 
102
114
  std::shared_ptr<tsi::RootCertInfo> RootCertInfoForTesting() {
@@ -114,9 +126,9 @@ class TlsChannelSecurityConnector final
114
126
  explicit TlsChannelCertificateWatcher(
115
127
  TlsChannelSecurityConnector* security_connector)
116
128
  : security_connector_(security_connector) {}
117
- void OnCertificatesChanged(
118
- std::shared_ptr<tsi::RootCertInfo> root_certs,
119
- std::optional<PemKeyCertPairList> key_cert_pairs) override;
129
+ void OnCertificatesChanged(std::shared_ptr<tsi::RootCertInfo> root_certs,
130
+ std::optional<KeyCertPairsOrSelector>
131
+ key_cert_pairs_or_selector) override;
120
132
  void OnError(grpc_error_handle root_cert_error,
121
133
  grpc_error_handle identity_cert_error) override;
122
134
 
@@ -167,7 +179,7 @@ class TlsChannelSecurityConnector final
167
179
  ABSL_GUARDED_BY(mu_) = nullptr;
168
180
  tsi_ssl_session_cache* ssl_session_cache_ ABSL_GUARDED_BY(mu_) = nullptr;
169
181
  RefCountedPtr<TlsSessionKeyLogger> tls_session_key_logger_;
170
- std::optional<PemKeyCertPairList> pem_key_cert_pair_list_
182
+ std::optional<KeyCertPairsOrSelector> key_cert_pairs_or_selector_
171
183
  ABSL_GUARDED_BY(mu_);
172
184
  std::shared_ptr<tsi::RootCertInfo> root_cert_info_ ABSL_GUARDED_BY(mu_);
173
185
  std::map<grpc_closure* /*on_peer_checked*/, ChannelPendingVerifierRequest*>
@@ -208,7 +220,16 @@ class TlsServerSecurityConnector final : public grpc_server_security_connector {
208
220
 
209
221
  std::optional<PemKeyCertPairList> KeyCertPairListForTesting() {
210
222
  MutexLock lock(&mu_);
211
- return pem_key_cert_pair_list_;
223
+ std::optional<PemKeyCertPairList> pem_key_cert_pairs;
224
+ if (key_cert_pairs_or_selector_.has_value()) {
225
+ Match(
226
+ *key_cert_pairs_or_selector_,
227
+ [&pem_key_cert_pairs](const PemKeyCertPairList& key_cert_pairs) {
228
+ pem_key_cert_pairs = key_cert_pairs;
229
+ },
230
+ [](const std::shared_ptr<CertificateSelector>&) {});
231
+ }
232
+ return pem_key_cert_pairs;
212
233
  }
213
234
 
214
235
  std::shared_ptr<tsi::RootCertInfo> RootCertInfoForTesting() {
@@ -226,9 +247,9 @@ class TlsServerSecurityConnector final : public grpc_server_security_connector {
226
247
  explicit TlsServerCertificateWatcher(
227
248
  TlsServerSecurityConnector* security_connector)
228
249
  : security_connector_(security_connector) {}
229
- void OnCertificatesChanged(
230
- std::shared_ptr<tsi::RootCertInfo> roots,
231
- std::optional<PemKeyCertPairList> key_cert_pairs) override;
250
+ void OnCertificatesChanged(std::shared_ptr<tsi::RootCertInfo> roots,
251
+ std::optional<KeyCertPairsOrSelector>
252
+ key_cert_pairs_or_selector) override;
232
253
 
233
254
  void OnError(grpc_error_handle root_cert_error,
234
255
  grpc_error_handle identity_cert_error) override;
@@ -276,7 +297,7 @@ class TlsServerSecurityConnector final : public grpc_server_security_connector {
276
297
  identity_certificate_watcher_ = nullptr;
277
298
  tsi_ssl_server_handshaker_factory* server_handshaker_factory_
278
299
  ABSL_GUARDED_BY(mu_) = nullptr;
279
- std::optional<PemKeyCertPairList> pem_key_cert_pair_list_
300
+ std::optional<KeyCertPairsOrSelector> key_cert_pairs_or_selector_
280
301
  ABSL_GUARDED_BY(mu_);
281
302
  std::shared_ptr<tsi::RootCertInfo> root_cert_info_ ABSL_GUARDED_BY(mu_);
282
303
  RefCountedPtr<TlsSessionKeyLogger> tls_session_key_logger_;
@@ -284,9 +284,8 @@ void LegacyChannelIdleFilter::StartIdleTimer() {
284
284
 
285
285
  void LegacyChannelIdleFilter::CloseChannel(absl::string_view reason) {
286
286
  auto* op = grpc_make_transport_op(nullptr);
287
- op->disconnect_with_error = grpc_error_set_int(
288
- GRPC_ERROR_CREATE(reason), StatusIntProperty::ChannelConnectivityState,
289
- GRPC_CHANNEL_IDLE);
287
+ op->disconnect_with_error = GRPC_ERROR_CREATE(reason);
288
+ op->go_idle = true;
290
289
  // Pass the transport op down to the channel stack.
291
290
  auto* elem = grpc_channel_stack_element(channel_stack_, 0);
292
291
  elem->filter->start_transport_op(elem, op);
@@ -305,14 +304,19 @@ void RegisterLegacyChannelIdleFilters(CoreConfiguration::Builder* builder) {
305
304
  return GetClientIdleTimeout(channel_args) != Duration::Infinity();
306
305
  });
307
306
 
308
- builder->channel_init()
309
- ->RegisterV2Filter<LegacyMaxAgeFilter>(GRPC_SERVER_CHANNEL)
310
- .FloatToTop()
311
- .ExcludeFromMinimalStack()
312
- .If([](const ChannelArgs& channel_args) {
313
- return LegacyMaxAgeFilter::Config::FromChannelArgs(channel_args)
314
- .enable();
315
- });
307
+ auto& max_age_registration =
308
+ builder->channel_init()
309
+ ->RegisterV2Filter<LegacyMaxAgeFilter>(GRPC_SERVER_CHANNEL)
310
+ .ExcludeFromMinimalStack()
311
+ .If([](const ChannelArgs& channel_args) {
312
+ return LegacyMaxAgeFilter::Config::FromChannelArgs(channel_args)
313
+ .enable();
314
+ });
315
+ if (IsFixV3FilterStackServerSideOrderingEnabled()) {
316
+ max_age_registration.SinkToBottom();
317
+ } else {
318
+ max_age_registration.FloatToTop();
319
+ }
316
320
  }
317
321
 
318
322
  LegacyMaxAgeFilter::LegacyMaxAgeFilter(grpc_channel_stack* channel_stack,
@@ -48,11 +48,6 @@ void RegisterHttpFilters(CoreConfiguration::Builder* builder) {
48
48
  .If(IsBuildingHttpLikeTransport)
49
49
  .After<HttpClientFilter>()
50
50
  .After<ClientMessageSizeFilter>();
51
- builder->channel_init()
52
- ->RegisterFilter<ServerCompressionFilter>(GRPC_SERVER_CHANNEL)
53
- .If(IsBuildingHttpLikeTransport)
54
- .After<HttpServerFilter>()
55
- .After<ServerMessageSizeFilter>();
56
51
  builder->channel_init()
57
52
  ->RegisterFilter<HttpClientFilter>(GRPC_CLIENT_SUBCHANNEL)
58
53
  .If(IsBuildingHttpLikeTransport)
@@ -61,15 +56,31 @@ void RegisterHttpFilters(CoreConfiguration::Builder* builder) {
61
56
  ->RegisterFilter<HttpClientFilter>(GRPC_CLIENT_DIRECT_CHANNEL)
62
57
  .If(IsBuildingHttpLikeTransport)
63
58
  .After<ClientMessageSizeFilter>();
64
- builder->channel_init()
65
- ->RegisterFilter<HttpServerFilter>(GRPC_SERVER_CHANNEL)
66
- .If(IsBuildingHttpLikeTransport)
67
- .After<ServerMessageSizeFilter>();
68
59
  builder->channel_init()
69
60
  ->RegisterFilter<HttpClientFilter>(GRPC_CLIENT_VIRTUAL_CHANNEL)
70
61
  .If(IsBuildingHttpLikeTransport);
62
+
63
+ // Server side filters.
64
+ auto& compression_reg =
65
+ builder->channel_init()
66
+ ->RegisterFilter<ServerCompressionFilter>(GRPC_SERVER_CHANNEL)
67
+ .If(IsBuildingHttpLikeTransport);
68
+ auto& http_server_reg =
69
+ builder->channel_init()
70
+ ->RegisterFilter<HttpServerFilter>(GRPC_SERVER_CHANNEL)
71
+ .If(IsBuildingHttpLikeTransport);
72
+
71
73
  builder->channel_init()
72
74
  ->RegisterFilter<HttpServerFilter>(GRPC_SERVER_VIRTUAL_CHANNEL)
73
75
  .If(IsBuildingHttpLikeTransport);
76
+
77
+ if (IsFixV3FilterStackServerSideOrderingEnabled()) {
78
+ compression_reg.Before<HttpServerFilter>()
79
+ .Before<ServerMessageSizeFilter>();
80
+ http_server_reg.Before<ServerMessageSizeFilter>();
81
+ } else {
82
+ compression_reg.After<HttpServerFilter>().After<ServerMessageSizeFilter>();
83
+ http_server_reg.After<ServerMessageSizeFilter>();
84
+ }
74
85
  }
75
86
  } // namespace grpc_core
@@ -44,21 +44,29 @@ namespace grpc_core {
44
44
  absl::Status RbacFilter::Call::OnClientInitialMetadata(ClientMetadata& md,
45
45
  RbacFilter* filter) {
46
46
  GRPC_LATENT_SEE_SCOPE("RbacFilter::Call::OnClientInitialMetadata");
47
- // Fetch and apply the rbac policy from the service config.
48
- auto* service_config_call_data = GetContext<ServiceConfigCallData>();
49
- auto* method_params = static_cast<RbacMethodParsedConfig*>(
50
- service_config_call_data->GetMethodParsedConfig(
51
- filter->service_config_parser_index_));
52
- if (method_params == nullptr) {
53
- return absl::PermissionDeniedError("No RBAC policy found.");
54
- } else {
55
- auto* authorization_engine =
56
- method_params->authorization_engine(filter->index_);
57
- if (authorization_engine
58
- ->Evaluate(EvaluateArgs(&md, &filter->per_channel_evaluate_args_))
59
- .type == AuthorizationEngine::Decision::Type::kDeny) {
60
- return absl::PermissionDeniedError("Unauthorized RPC rejected");
47
+ if (!IsXdsServerFilterChainPerRouteEnabled()) {
48
+ // Fetch and apply the rbac policy from the service config.
49
+ auto* service_config_call_data = GetContext<ServiceConfigCallData>();
50
+ auto* method_params = static_cast<RbacMethodParsedConfig*>(
51
+ service_config_call_data->GetMethodParsedConfig(
52
+ filter->service_config_parser_index_));
53
+ if (method_params == nullptr) {
54
+ return absl::PermissionDeniedError("No RBAC policy found.");
55
+ } else {
56
+ auto* authorization_engine =
57
+ method_params->authorization_engine(filter->index_);
58
+ if (authorization_engine
59
+ ->Evaluate(EvaluateArgs(&md, &filter->per_channel_evaluate_args_))
60
+ .type == AuthorizationEngine::Decision::Type::kDeny) {
61
+ return absl::PermissionDeniedError("Unauthorized RPC rejected");
62
+ }
61
63
  }
64
+ return absl::OkStatus();
65
+ }
66
+ auto decision = filter->authorization_engine_.Evaluate(
67
+ EvaluateArgs(&md, &filter->per_channel_evaluate_args_));
68
+ if (decision.type == AuthorizationEngine::Decision::Type::kDeny) {
69
+ return absl::PermissionDeniedError("Unauthorized RPC rejected");
62
70
  }
63
71
  return absl::OkStatus();
64
72
  }
@@ -66,12 +74,6 @@ absl::Status RbacFilter::Call::OnClientInitialMetadata(ClientMetadata& md,
66
74
  const grpc_channel_filter RbacFilter::kFilterVtable =
67
75
  MakePromiseBasedFilter<RbacFilter, FilterEndpoint::kServer>();
68
76
 
69
- RbacFilter::RbacFilter(size_t index,
70
- EvaluateArgs::PerChannelArgs per_channel_evaluate_args)
71
- : index_(index),
72
- service_config_parser_index_(RbacServiceConfigParser::ParserIndex()),
73
- per_channel_evaluate_args_(std::move(per_channel_evaluate_args)) {}
74
-
75
77
  absl::StatusOr<std::unique_ptr<RbacFilter>> RbacFilter::Create(
76
78
  const ChannelArgs& args, ChannelFilter::Args filter_args) {
77
79
  auto* auth_context = args.GetObject<grpc_auth_context>();
@@ -84,11 +86,31 @@ absl::StatusOr<std::unique_ptr<RbacFilter>> RbacFilter::Create(
84
86
  // side.
85
87
  return GRPC_ERROR_CREATE("No transport configured");
86
88
  }
89
+ if (!IsXdsServerFilterChainPerRouteEnabled()) {
90
+ return std::make_unique<RbacFilter>(
91
+ filter_args.instance_id(), Rbac(),
92
+ EvaluateArgs::PerChannelArgs(auth_context, args));
93
+ }
94
+ if (filter_args.config() == nullptr) {
95
+ return absl::InternalError("no config passed to RBAC filter");
96
+ }
97
+ if (filter_args.config()->type() != Config::Type()) {
98
+ return absl::InternalError(
99
+ absl::StrCat("wrong config type passed to RBAC filter: ",
100
+ filter_args.config()->type().name()));
101
+ }
87
102
  return std::make_unique<RbacFilter>(
88
- filter_args.instance_id(),
103
+ /*instance_id=*/0, DownCast<const Config&>(*filter_args.config()).rbac,
89
104
  EvaluateArgs::PerChannelArgs(auth_context, args));
90
105
  }
91
106
 
107
+ RbacFilter::RbacFilter(size_t index, const Rbac& rbac,
108
+ EvaluateArgs::PerChannelArgs per_channel_evaluate_args)
109
+ : index_(index),
110
+ service_config_parser_index_(RbacServiceConfigParser::ParserIndex()),
111
+ authorization_engine_(rbac),
112
+ per_channel_evaluate_args_(std::move(per_channel_evaluate_args)) {}
113
+
92
114
  void RbacFilterRegister(CoreConfiguration::Builder* builder) {
93
115
  RbacServiceConfigParser::Register(builder);
94
116
  }
@@ -25,6 +25,8 @@
25
25
  #include "src/core/lib/channel/promise_based_filter.h"
26
26
  #include "src/core/lib/promise/arena_promise.h"
27
27
  #include "src/core/lib/security/authorization/evaluate_args.h"
28
+ #include "src/core/lib/security/authorization/grpc_authorization_engine.h"
29
+ #include "src/core/lib/security/authorization/rbac_policy.h"
28
30
  #include "src/core/lib/transport/transport.h"
29
31
  #include "absl/status/statusor.h"
30
32
 
@@ -34,6 +36,20 @@ namespace grpc_core {
34
36
  // HTTP RBAC filter. Also serves as the type for channel data for the filter.
35
37
  class RbacFilter : public ImplementChannelFilter<RbacFilter> {
36
38
  public:
39
+ struct Config final : public FilterConfig {
40
+ static UniqueTypeName Type() {
41
+ return GRPC_UNIQUE_TYPE_NAME_HERE("rbac_filter_config");
42
+ }
43
+ UniqueTypeName type() const override { return Type(); }
44
+
45
+ bool Equals(const FilterConfig& other) const override {
46
+ return rbac == DownCast<const Config&>(other).rbac;
47
+ }
48
+ std::string ToString() const override { return rbac.ToString(); }
49
+
50
+ Rbac rbac;
51
+ };
52
+
37
53
  // This channel filter is intended to be used by connections on xDS enabled
38
54
  // servers configured with RBAC. The RBAC filter fetches the RBAC policy from
39
55
  // the method config of service config returned by the ServerConfigSelector,
@@ -45,7 +61,7 @@ class RbacFilter : public ImplementChannelFilter<RbacFilter> {
45
61
  static absl::StatusOr<std::unique_ptr<RbacFilter>> Create(
46
62
  const ChannelArgs& args, ChannelFilter::Args filter_args);
47
63
 
48
- RbacFilter(size_t index,
64
+ RbacFilter(size_t index, const Rbac& rbac,
49
65
  EvaluateArgs::PerChannelArgs per_channel_evaluate_args);
50
66
 
51
67
  class Call {
@@ -64,10 +80,12 @@ class RbacFilter : public ImplementChannelFilter<RbacFilter> {
64
80
  };
65
81
 
66
82
  private:
67
- // The index of this filter instance among instances of the same filter.
83
+ // TODO(roth): Remove these fields as part of removing the
84
+ // xds_server_filter_chain_per_route experiment.
68
85
  size_t index_;
69
- // Assigned index for service config data from the parser.
70
86
  const size_t service_config_parser_index_;
87
+
88
+ GrpcAuthorizationEngine authorization_engine_;
71
89
  // Per channel args used for authorization.
72
90
  EvaluateArgs::PerChannelArgs per_channel_evaluate_args_;
73
91
  };
@@ -564,7 +564,7 @@ void RbacConfig::RbacPolicy::Rules::Policy::Permission::JsonPostLoad(
564
564
  /*required=*/false);
565
565
  if (not_rule.has_value()) {
566
566
  permission = std::make_unique<Rbac::Permission>(
567
- Rbac::Permission::MakeNotPermission(std::move(*not_rule->permission)));
567
+ Rbac::Permission::MakeNotPermission(std::move(not_rule->permission)));
568
568
  return;
569
569
  }
570
570
  if (errors->size() == original_error_size) {
@@ -719,7 +719,7 @@ void RbacConfig::RbacPolicy::Rules::Policy::Principal::JsonPostLoad(
719
719
  /*required=*/false);
720
720
  if (not_rule.has_value()) {
721
721
  principal = std::make_unique<Rbac::Principal>(
722
- Rbac::Principal::MakeNotPrincipal(std::move(*not_rule->principal)));
722
+ Rbac::Principal::MakeNotPrincipal(std::move(not_rule->principal)));
723
723
  return;
724
724
  }
725
725
  if (errors->size() == original_error_size) {
@@ -209,7 +209,7 @@ void Chttp2Connector::OnHandshakeDone(absl::StatusOr<HandshakerArgs*> result) {
209
209
  } else {
210
210
  GRPC_HTTP2_CONNECTOR_DLOG
211
211
  << "Chttp2Connector::OnHandshakeDone creating PH2 transport";
212
- // TODO(tjagtap) : [PH2][P1] : Validate this code block thoroughly once
212
+ // TODO(tjagtap) : [PH2][P2] : Validate this code block thoroughly once
213
213
  // the ping pong test is in place.
214
214
  std::unique_ptr<grpc_event_engine::experimental::EventEngine::Endpoint>
215
215
  event_engine_endpoint = grpc_event_engine::experimental::