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
@@ -16,7 +16,6 @@
16
16
 
17
17
  #include "src/core/xds/grpc/xds_http_rbac_filter.h"
18
18
 
19
- #include <grpc/support/json.h>
20
19
  #include <stddef.h>
21
20
  #include <stdint.h>
22
21
 
@@ -506,19 +505,19 @@ Json ParseHttpRbacToJson(const XdsResourceType::DecodeContext& context,
506
505
 
507
506
  } // namespace
508
507
 
509
- absl::string_view XdsHttpRbacFilter::ConfigProtoName() const {
508
+ absl::string_view XdsHttpRbacFilterFactory::ConfigProtoName() const {
510
509
  return "envoy.extensions.filters.http.rbac.v3.RBAC";
511
510
  }
512
511
 
513
- absl::string_view XdsHttpRbacFilter::OverrideConfigProtoName() const {
512
+ absl::string_view XdsHttpRbacFilterFactory::OverrideConfigProtoName() const {
514
513
  return "envoy.extensions.filters.http.rbac.v3.RBACPerRoute";
515
514
  }
516
515
 
517
- void XdsHttpRbacFilter::PopulateSymtab(upb_DefPool* symtab) const {
516
+ void XdsHttpRbacFilterFactory::PopulateSymtab(upb_DefPool* symtab) const {
518
517
  envoy_extensions_filters_http_rbac_v3_RBAC_getmsgdef(symtab);
519
518
  }
520
519
 
521
- std::optional<Json> XdsHttpRbacFilter::GenerateFilterConfig(
520
+ std::optional<Json> XdsHttpRbacFilterFactory::GenerateFilterConfig(
522
521
  absl::string_view /*instance_name*/,
523
522
  const XdsResourceType::DecodeContext& context,
524
523
  const XdsExtension& extension, ValidationErrors* errors) const {
@@ -538,7 +537,7 @@ std::optional<Json> XdsHttpRbacFilter::GenerateFilterConfig(
538
537
  return ParseHttpRbacToJson(context, rbac, errors);
539
538
  }
540
539
 
541
- std::optional<Json> XdsHttpRbacFilter::GenerateFilterConfigOverride(
540
+ std::optional<Json> XdsHttpRbacFilterFactory::GenerateFilterConfigOverride(
542
541
  absl::string_view /*instance_name*/,
543
542
  const XdsResourceType::DecodeContext& context,
544
543
  const XdsExtension& extension, ValidationErrors* errors) const {
@@ -568,23 +567,23 @@ std::optional<Json> XdsHttpRbacFilter::GenerateFilterConfigOverride(
568
567
  return rbac_json;
569
568
  }
570
569
 
571
- void XdsHttpRbacFilter::AddFilter(
570
+ void XdsHttpRbacFilterFactory::AddFilter(
572
571
  FilterChainBuilder& builder,
573
572
  RefCountedPtr<const FilterConfig> config) const {
574
573
  builder.AddFilter<RbacFilter>(std::move(config));
575
574
  }
576
575
 
577
- const grpc_channel_filter* XdsHttpRbacFilter::channel_filter() const {
576
+ const grpc_channel_filter* XdsHttpRbacFilterFactory::channel_filter() const {
578
577
  return &RbacFilter::kFilterVtable;
579
578
  }
580
579
 
581
- ChannelArgs XdsHttpRbacFilter::ModifyChannelArgs(
580
+ ChannelArgs XdsHttpRbacFilterFactory::ModifyChannelArgs(
582
581
  const ChannelArgs& args) const {
583
582
  return args.Set(GRPC_ARG_PARSE_RBAC_METHOD_CONFIG, 1);
584
583
  }
585
584
 
586
- absl::StatusOr<XdsHttpFilterImpl::ServiceConfigJsonEntry>
587
- XdsHttpRbacFilter::GenerateMethodConfig(
585
+ absl::StatusOr<XdsHttpFilterFactory::ServiceConfigJsonEntry>
586
+ XdsHttpRbacFilterFactory::GenerateMethodConfig(
588
587
  const Json& hcm_filter_config, const Json* filter_config_override) const {
589
588
  const Json& policy_json = filter_config_override != nullptr
590
589
  ? *filter_config_override
@@ -593,28 +592,407 @@ XdsHttpRbacFilter::GenerateMethodConfig(
593
592
  return ServiceConfigJsonEntry{"rbacPolicy", JsonDump(policy_json)};
594
593
  }
595
594
 
596
- absl::StatusOr<XdsHttpFilterImpl::ServiceConfigJsonEntry>
597
- XdsHttpRbacFilter::GenerateServiceConfig(
595
+ absl::StatusOr<XdsHttpFilterFactory::ServiceConfigJsonEntry>
596
+ XdsHttpRbacFilterFactory::GenerateServiceConfig(
598
597
  const Json& /*hcm_filter_config*/) const {
599
598
  return ServiceConfigJsonEntry{"", ""};
600
599
  }
601
600
 
602
- RefCountedPtr<const FilterConfig> XdsHttpRbacFilter::ParseTopLevelConfig(
601
+ namespace {
602
+
603
+ Rbac::CidrRange ParseCidrRange(const envoy_config_core_v3_CidrRange* range) {
604
+ Rbac::CidrRange cidr_range;
605
+ cidr_range.address_prefix = UpbStringToStdString(
606
+ envoy_config_core_v3_CidrRange_address_prefix(range));
607
+ cidr_range.prefix_len =
608
+ ParseUInt32Value(envoy_config_core_v3_CidrRange_prefix_len(range))
609
+ .value_or(0);
610
+ return cidr_range;
611
+ }
612
+
613
+ StringMatcher ParsePathMatcher(const XdsResourceType::DecodeContext& context,
614
+ const envoy_type_matcher_v3_PathMatcher* matcher,
615
+ ValidationErrors* errors) {
616
+ ValidationErrors::ScopedField field(errors, ".path");
617
+ const auto* path = envoy_type_matcher_v3_PathMatcher_path(matcher);
618
+ if (path == nullptr) {
619
+ errors->AddError("field not present");
620
+ return StringMatcher();
621
+ }
622
+ return StringMatcherParse(context, path, errors);
623
+ }
624
+
625
+ HeaderMatcher ParseHeaderMatcher(
626
+ const XdsResourceType::DecodeContext& context,
627
+ const envoy_config_route_v3_HeaderMatcher* matcher,
628
+ ValidationErrors* errors) {
629
+ HeaderMatcher header_matcher =
630
+ ParseXdsHeaderMatcher(context, matcher, errors);
631
+ ValidationErrors::ScopedField field(errors, ".name");
632
+ if (header_matcher.name() == ":scheme") {
633
+ errors->AddError("':scheme' not allowed in header");
634
+ } else if (absl::StartsWith(header_matcher.name(), "grpc-")) {
635
+ errors->AddError("'grpc-' prefixes not allowed in header");
636
+ }
637
+ return header_matcher;
638
+ }
639
+
640
+ std::unique_ptr<Rbac::Permission> ParsePermission(
641
+ const XdsResourceType::DecodeContext& context,
642
+ const envoy_config_rbac_v3_Permission* permission, size_t depth,
643
+ ValidationErrors* errors);
644
+
645
+ std::vector<std::unique_ptr<Rbac::Permission>> ParsePermissionSet(
646
+ const XdsResourceType::DecodeContext& context,
647
+ const envoy_config_rbac_v3_Permission_Set* set, size_t depth,
648
+ ValidationErrors* errors) {
649
+ std::vector<std::unique_ptr<Rbac::Permission>> result;
650
+ size_t size;
651
+ const envoy_config_rbac_v3_Permission* const* rules =
652
+ envoy_config_rbac_v3_Permission_Set_rules(set, &size);
653
+ for (size_t i = 0; i < size; ++i) {
654
+ ValidationErrors::ScopedField field(errors,
655
+ absl::StrCat(".rules[", i, "]"));
656
+ result.push_back(ParsePermission(context, rules[i], depth + 1, errors));
657
+ }
658
+ return result;
659
+ };
660
+
661
+ std::unique_ptr<Rbac::Permission> ParsePermission(
662
+ const XdsResourceType::DecodeContext& context,
663
+ const envoy_config_rbac_v3_Permission* permission, size_t depth,
664
+ ValidationErrors* errors) {
665
+ if (depth > 16) {
666
+ errors->AddError("exceeded max recursion depth");
667
+ return nullptr;
668
+ }
669
+ auto result = std::make_unique<Rbac::Permission>();
670
+ if (envoy_config_rbac_v3_Permission_has_and_rules(permission)) {
671
+ ValidationErrors::ScopedField field(errors, ".and_permission");
672
+ *result = Rbac::Permission::MakeAndPermission(ParsePermissionSet(
673
+ context, envoy_config_rbac_v3_Permission_and_rules(permission), depth,
674
+ errors));
675
+ } else if (envoy_config_rbac_v3_Permission_has_or_rules(permission)) {
676
+ ValidationErrors::ScopedField field(errors, ".or_permission");
677
+ *result = Rbac::Permission::MakeOrPermission(ParsePermissionSet(
678
+ context, envoy_config_rbac_v3_Permission_or_rules(permission), depth,
679
+ errors));
680
+ } else if (envoy_config_rbac_v3_Permission_has_any(permission)) {
681
+ *result = Rbac::Permission::MakeAnyPermission();
682
+ } else if (envoy_config_rbac_v3_Permission_has_header(permission)) {
683
+ ValidationErrors::ScopedField field(errors, ".header");
684
+ *result = Rbac::Permission::MakeHeaderPermission(ParseHeaderMatcher(
685
+ context, envoy_config_rbac_v3_Permission_header(permission), errors));
686
+ } else if (envoy_config_rbac_v3_Permission_has_url_path(permission)) {
687
+ ValidationErrors::ScopedField field(errors, ".url_path");
688
+ *result = Rbac::Permission::MakePathPermission(ParsePathMatcher(
689
+ context, envoy_config_rbac_v3_Permission_url_path(permission), errors));
690
+ } else if (envoy_config_rbac_v3_Permission_has_destination_ip(permission)) {
691
+ *result = Rbac::Permission::MakeDestIpPermission(ParseCidrRange(
692
+ envoy_config_rbac_v3_Permission_destination_ip(permission)));
693
+ } else if (envoy_config_rbac_v3_Permission_has_destination_port(permission)) {
694
+ *result = Rbac::Permission::MakeDestPortPermission(
695
+ envoy_config_rbac_v3_Permission_destination_port(permission));
696
+ } else if (envoy_config_rbac_v3_Permission_has_metadata(permission)) {
697
+ const auto* metadata = envoy_config_rbac_v3_Permission_metadata(permission);
698
+ // The fields "filter", "path" and "value" are irrelevant to gRPC as per
699
+ // https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md and are not
700
+ // being parsed.
701
+ *result = Rbac::Permission::MakeMetadataPermission(
702
+ envoy_type_matcher_v3_MetadataMatcher_invert(metadata));
703
+ } else if (envoy_config_rbac_v3_Permission_has_not_rule(permission)) {
704
+ ValidationErrors::ScopedField field(errors, ".not_rule");
705
+ auto not_permission = ParsePermission(
706
+ context, envoy_config_rbac_v3_Permission_not_rule(permission),
707
+ depth + 1, errors);
708
+ *result = Rbac::Permission::MakeNotPermission(std::move(not_permission));
709
+ } else if (envoy_config_rbac_v3_Permission_has_requested_server_name(
710
+ permission)) {
711
+ ValidationErrors::ScopedField field(errors, ".requested_server_name");
712
+ *result = Rbac::Permission::MakeReqServerNamePermission(StringMatcherParse(
713
+ context,
714
+ envoy_config_rbac_v3_Permission_requested_server_name(permission),
715
+ errors));
716
+ } else {
717
+ errors->AddError("invalid rule");
718
+ }
719
+ return result;
720
+ }
721
+
722
+ std::unique_ptr<Rbac::Principal> ParsePrincipal(
723
+ const XdsResourceType::DecodeContext& context,
724
+ const envoy_config_rbac_v3_Principal* principal, size_t depth,
725
+ ValidationErrors* errors);
726
+
727
+ std::vector<std::unique_ptr<Rbac::Principal>> ParsePrincipalSet(
728
+ const XdsResourceType::DecodeContext& context,
729
+ const envoy_config_rbac_v3_Principal_Set* set, size_t depth,
730
+ ValidationErrors* errors) {
731
+ std::vector<std::unique_ptr<Rbac::Principal>> result;
732
+ size_t size;
733
+ const envoy_config_rbac_v3_Principal* const* ids =
734
+ envoy_config_rbac_v3_Principal_Set_ids(set, &size);
735
+ for (size_t i = 0; i < size; ++i) {
736
+ ValidationErrors::ScopedField field(errors, absl::StrCat(".ids[", i, "]"));
737
+ result.push_back(ParsePrincipal(context, ids[i], depth + 1, errors));
738
+ }
739
+ return result;
740
+ };
741
+
742
+ std::unique_ptr<Rbac::Principal> ParsePrincipal(
743
+ const XdsResourceType::DecodeContext& context,
744
+ const envoy_config_rbac_v3_Principal* principal, size_t depth,
745
+ ValidationErrors* errors) {
746
+ if (depth > 16) {
747
+ errors->AddError("exceeded max recursion depth");
748
+ return nullptr;
749
+ }
750
+ auto result = std::make_unique<Rbac::Principal>();
751
+ if (envoy_config_rbac_v3_Principal_has_and_ids(principal)) {
752
+ ValidationErrors::ScopedField field(errors, ".and_ids");
753
+ *result = Rbac::Principal::MakeAndPrincipal(ParsePrincipalSet(
754
+ context, envoy_config_rbac_v3_Principal_and_ids(principal), depth,
755
+ errors));
756
+ } else if (envoy_config_rbac_v3_Principal_has_or_ids(principal)) {
757
+ ValidationErrors::ScopedField field(errors, ".or_ids");
758
+ *result = Rbac::Principal::MakeOrPrincipal(ParsePrincipalSet(
759
+ context, envoy_config_rbac_v3_Principal_or_ids(principal), depth,
760
+ errors));
761
+ } else if (envoy_config_rbac_v3_Principal_has_any(principal)) {
762
+ *result = Rbac::Principal::MakeAnyPrincipal();
763
+ } else if (envoy_config_rbac_v3_Principal_has_authenticated(principal)) {
764
+ std::optional<StringMatcher> string_matcher;
765
+ const auto* principal_name =
766
+ envoy_config_rbac_v3_Principal_Authenticated_principal_name(
767
+ envoy_config_rbac_v3_Principal_authenticated(principal));
768
+ if (principal_name != nullptr) {
769
+ ValidationErrors::ScopedField field(errors,
770
+ ".authenticated.principal_name");
771
+ string_matcher = StringMatcherParse(context, principal_name, errors);
772
+ }
773
+ *result =
774
+ Rbac::Principal::MakeAuthenticatedPrincipal(std::move(string_matcher));
775
+ } else if (envoy_config_rbac_v3_Principal_has_source_ip(principal)) {
776
+ *result = Rbac::Principal::MakeSourceIpPrincipal(
777
+ ParseCidrRange(envoy_config_rbac_v3_Principal_source_ip(principal)));
778
+ } else if (envoy_config_rbac_v3_Principal_has_direct_remote_ip(principal)) {
779
+ *result = Rbac::Principal::MakeDirectRemoteIpPrincipal(ParseCidrRange(
780
+ envoy_config_rbac_v3_Principal_direct_remote_ip(principal)));
781
+ } else if (envoy_config_rbac_v3_Principal_has_remote_ip(principal)) {
782
+ *result = Rbac::Principal::MakeRemoteIpPrincipal(
783
+ ParseCidrRange(envoy_config_rbac_v3_Principal_remote_ip(principal)));
784
+ } else if (envoy_config_rbac_v3_Principal_has_header(principal)) {
785
+ ValidationErrors::ScopedField field(errors, ".header");
786
+ *result = Rbac::Principal::MakeHeaderPrincipal(ParseHeaderMatcher(
787
+ context, envoy_config_rbac_v3_Principal_header(principal), errors));
788
+ } else if (envoy_config_rbac_v3_Principal_has_url_path(principal)) {
789
+ ValidationErrors::ScopedField field(errors, ".url_path");
790
+ *result = Rbac::Principal::MakePathPrincipal(ParsePathMatcher(
791
+ context, envoy_config_rbac_v3_Principal_url_path(principal), errors));
792
+ } else if (envoy_config_rbac_v3_Principal_has_metadata(principal)) {
793
+ const auto* metadata = envoy_config_rbac_v3_Principal_metadata(principal);
794
+ // The fields "filter", "path" and "value" are irrelevant to gRPC as per
795
+ // https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md and are not
796
+ // being parsed.
797
+ *result = Rbac::Principal::MakeMetadataPrincipal(
798
+ envoy_type_matcher_v3_MetadataMatcher_invert(metadata));
799
+ } else if (envoy_config_rbac_v3_Principal_has_not_id(principal)) {
800
+ ValidationErrors::ScopedField field(errors, ".not_id");
801
+ auto not_principal = ParsePrincipal(
802
+ context, envoy_config_rbac_v3_Principal_not_id(principal), depth + 1,
803
+ errors);
804
+ *result = Rbac::Principal::MakeNotPrincipal(std::move(not_principal));
805
+ } else {
806
+ errors->AddError("invalid rule");
807
+ }
808
+ return result;
809
+ }
810
+
811
+ Rbac::Policy ParsePolicy(const XdsResourceType::DecodeContext& context,
812
+ const envoy_config_rbac_v3_Policy* policy,
813
+ ValidationErrors* errors) {
814
+ Rbac::Policy result;
815
+ // permissions
816
+ size_t size;
817
+ const envoy_config_rbac_v3_Permission* const* permissions =
818
+ envoy_config_rbac_v3_Policy_permissions(policy, &size);
819
+ std::vector<std::unique_ptr<Rbac::Permission>> or_permissions;
820
+ for (size_t i = 0; i < size; ++i) {
821
+ ValidationErrors::ScopedField field(errors,
822
+ absl::StrCat(".permissions[", i, "]"));
823
+ or_permissions.push_back(
824
+ ParsePermission(context, permissions[i], /*depth=*/0, errors));
825
+ }
826
+ result.permissions =
827
+ Rbac::Permission::MakeOrPermission(std::move(or_permissions));
828
+ // principals
829
+ const envoy_config_rbac_v3_Principal* const* principals =
830
+ envoy_config_rbac_v3_Policy_principals(policy, &size);
831
+ std::vector<std::unique_ptr<Rbac::Principal>> or_principals;
832
+ for (size_t i = 0; i < size; ++i) {
833
+ ValidationErrors::ScopedField field(errors,
834
+ absl::StrCat(".principals[", i, "]"));
835
+ or_principals.push_back(
836
+ ParsePrincipal(context, principals[i], /*depth=*/0, errors));
837
+ }
838
+ result.principals =
839
+ Rbac::Principal::MakeOrPrincipal(std::move(or_principals));
840
+ // condition
841
+ if (envoy_config_rbac_v3_Policy_has_condition(policy)) {
842
+ ValidationErrors::ScopedField field(errors, ".condition");
843
+ errors->AddError("condition not supported");
844
+ }
845
+ // checked_condition
846
+ if (envoy_config_rbac_v3_Policy_has_checked_condition(policy)) {
847
+ ValidationErrors::ScopedField field(errors, ".checked_condition");
848
+ errors->AddError("checked condition not supported");
849
+ }
850
+ return result;
851
+ }
852
+
853
+ Rbac ParseXdsRbac(const XdsResourceType::DecodeContext& context,
854
+ const envoy_extensions_filters_http_rbac_v3_RBAC* rbac,
855
+ ValidationErrors* errors) {
856
+ const auto* rules = envoy_extensions_filters_http_rbac_v3_RBAC_rules(rbac);
857
+ if (rules == nullptr) {
858
+ // No enforcing to be applied. An empty deny policy with an empty map
859
+ // is equivalent to no enforcing.
860
+ return Rbac("", Rbac::Action::kDeny, {});
861
+ }
862
+ ValidationErrors::ScopedField field(errors, ".rules");
863
+ Rbac result;
864
+ // action
865
+ switch (envoy_config_rbac_v3_RBAC_action(rules)) {
866
+ case envoy_config_rbac_v3_RBAC_ALLOW:
867
+ result.action = Rbac::Action::kAllow;
868
+ break;
869
+ case envoy_config_rbac_v3_RBAC_DENY:
870
+ result.action = Rbac::Action::kDeny;
871
+ break;
872
+ case envoy_config_rbac_v3_RBAC_LOG:
873
+ // Treat Log action as RBAC being absent.
874
+ // No enforcing to be applied. An empty deny policy with an empty map
875
+ // is equivalent to no enforcing.
876
+ return Rbac("", Rbac::Action::kDeny, {});
877
+ default:
878
+ ValidationErrors::ScopedField field(errors, ".action");
879
+ errors->AddError("unknown action");
880
+ }
881
+ // policies
882
+ if (envoy_config_rbac_v3_RBAC_policies_size(rules) != 0) {
883
+ size_t iter = kUpb_Map_Begin;
884
+ upb_StringView key_view;
885
+ const envoy_config_rbac_v3_Policy* val;
886
+ while (envoy_config_rbac_v3_RBAC_policies_next(rules, &key_view, &val,
887
+ &iter)) {
888
+ absl::string_view key = UpbStringToAbsl(key_view);
889
+ ValidationErrors::ScopedField field(errors,
890
+ absl::StrCat(".policies[", key, "]"));
891
+ result.policies[std::string(key)] = ParsePolicy(context, val, errors);
892
+ }
893
+ }
894
+ // audit_logging_options
895
+ // TODO(lwge): Remove env var guard once the feature is stable.
896
+ if (IsExperimentEnvVarEnabled("GRPC_EXPERIMENTAL_XDS_RBAC_AUDIT_LOGGING") &&
897
+ envoy_config_rbac_v3_RBAC_has_audit_logging_options(rules)) {
898
+ ValidationErrors::ScopedField field(errors, ".audit_logging_options");
899
+ const auto* audit_logging_options =
900
+ envoy_config_rbac_v3_RBAC_audit_logging_options(rules);
901
+ int32_t audit_condition =
902
+ envoy_config_rbac_v3_RBAC_AuditLoggingOptions_audit_condition(
903
+ audit_logging_options);
904
+ switch (audit_condition) {
905
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_NONE:
906
+ result.audit_condition = Rbac::AuditCondition::kNone;
907
+ break;
908
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_ON_DENY:
909
+ result.audit_condition = Rbac::AuditCondition::kOnDeny;
910
+ break;
911
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_ON_ALLOW:
912
+ result.audit_condition = Rbac::AuditCondition::kOnAllow;
913
+ break;
914
+ case envoy_config_rbac_v3_RBAC_AuditLoggingOptions_ON_DENY_AND_ALLOW:
915
+ result.audit_condition = Rbac::AuditCondition::kOnDenyAndAllow;
916
+ break;
917
+ default:
918
+ ValidationErrors::ScopedField field(errors, ".audit_condition");
919
+ errors->AddError("invalid audit condition");
920
+ }
921
+ size_t size;
922
+ const envoy_config_rbac_v3_RBAC_AuditLoggingOptions_AuditLoggerConfig* const*
923
+ logger_configs =
924
+ envoy_config_rbac_v3_RBAC_AuditLoggingOptions_logger_configs(
925
+ audit_logging_options, &size);
926
+ const auto& registry =
927
+ DownCast<const GrpcXdsBootstrap&>(context.client->bootstrap())
928
+ .audit_logger_registry();
929
+ for (size_t i = 0; i < size; ++i) {
930
+ ValidationErrors::ScopedField field(
931
+ errors, absl::StrCat(".logger_configs[", i, "]"));
932
+ auto config = registry.ParseXdsAuditLoggerConfig(
933
+ context, logger_configs[i], errors);
934
+ // Config will be null if audit logger is unsupported.
935
+ // Note that this may not be an error if the logger is optional.
936
+ if (config != nullptr) result.logger_configs.push_back(std::move(config));
937
+ }
938
+ }
939
+ return result;
940
+ }
941
+
942
+ } // namespace
943
+
944
+ RefCountedPtr<const FilterConfig> XdsHttpRbacFilterFactory::ParseTopLevelConfig(
603
945
  absl::string_view /*instance_name*/,
604
- const XdsResourceType::DecodeContext& /*context*/,
605
- const XdsExtension& /*extension*/, ValidationErrors* /*errors*/) const {
606
- // TODO(roth): Implement this as part of migrating the server side to
607
- // the new approach for passing xDS HTTP filter configs.
608
- return nullptr;
946
+ const XdsResourceType::DecodeContext& context,
947
+ const XdsExtension& extension, ValidationErrors* errors) const {
948
+ const absl::string_view* serialized_filter_config =
949
+ std::get_if<absl::string_view>(&extension.value);
950
+ if (serialized_filter_config == nullptr) {
951
+ errors->AddError("could not parse HTTP RBAC filter config");
952
+ return nullptr;
953
+ }
954
+ auto* rbac = envoy_extensions_filters_http_rbac_v3_RBAC_parse(
955
+ serialized_filter_config->data(), serialized_filter_config->size(),
956
+ context.arena);
957
+ if (rbac == nullptr) {
958
+ errors->AddError("could not parse HTTP RBAC filter config");
959
+ return nullptr;
960
+ }
961
+ auto config = MakeRefCounted<RbacFilter::Config>();
962
+ config->rbac = ParseXdsRbac(context, rbac, errors);
963
+ return config;
609
964
  }
610
965
 
611
- RefCountedPtr<const FilterConfig> XdsHttpRbacFilter::ParseOverrideConfig(
966
+ RefCountedPtr<const FilterConfig> XdsHttpRbacFilterFactory::ParseOverrideConfig(
612
967
  absl::string_view /*instance_name*/,
613
- const XdsResourceType::DecodeContext& /*context*/,
614
- const XdsExtension& /*extension*/, ValidationErrors* /*errors*/) const {
615
- // TODO(roth): Implement this as part of migrating the server side to
616
- // the new approach for passing xDS HTTP filter configs.
617
- return nullptr;
968
+ const XdsResourceType::DecodeContext& context,
969
+ const XdsExtension& extension, ValidationErrors* errors) const {
970
+ const absl::string_view* serialized_filter_config =
971
+ std::get_if<absl::string_view>(&extension.value);
972
+ if (serialized_filter_config == nullptr) {
973
+ errors->AddError("could not parse RBACPerRoute");
974
+ return nullptr;
975
+ }
976
+ auto* rbac_per_route =
977
+ envoy_extensions_filters_http_rbac_v3_RBACPerRoute_parse(
978
+ serialized_filter_config->data(), serialized_filter_config->size(),
979
+ context.arena);
980
+ if (rbac_per_route == nullptr) {
981
+ errors->AddError("could not parse RBACPerRoute");
982
+ return nullptr;
983
+ }
984
+ auto config = MakeRefCounted<RbacFilter::Config>();
985
+ const auto* rbac =
986
+ envoy_extensions_filters_http_rbac_v3_RBACPerRoute_rbac(rbac_per_route);
987
+ if (rbac == nullptr) {
988
+ // No enforcing to be applied. An empty deny policy with an empty map
989
+ // is equivalent to no enforcing.
990
+ config->rbac = Rbac("", Rbac::Action::kDeny, {});
991
+ } else {
992
+ ValidationErrors::ScopedField field(errors, ".rbac");
993
+ config->rbac = ParseXdsRbac(context, rbac, errors);
994
+ }
995
+ return config;
618
996
  }
619
997
 
620
998
  } // namespace grpc_core
@@ -17,8 +17,6 @@
17
17
  #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_HTTP_RBAC_FILTER_H
18
18
  #define GRPC_SRC_CORE_XDS_GRPC_XDS_HTTP_RBAC_FILTER_H
19
19
 
20
- #include <grpc/support/port_platform.h>
21
-
22
20
  #include <optional>
23
21
 
24
22
  #include "src/core/lib/channel/channel_args.h"
@@ -33,7 +31,7 @@
33
31
 
34
32
  namespace grpc_core {
35
33
 
36
- class XdsHttpRbacFilter final : public XdsHttpFilterImpl {
34
+ class XdsHttpRbacFilterFactory final : public XdsHttpFilterFactory {
37
35
  public:
38
36
  absl::string_view ConfigProtoName() const override;
39
37
  absl::string_view OverrideConfigProtoName() const override;
@@ -16,9 +16,6 @@
16
16
 
17
17
  #include "src/core/xds/grpc/xds_http_stateful_session_filter.h"
18
18
 
19
- #include <grpc/support/json.h>
20
- #include <grpc/support/port_platform.h>
21
-
22
19
  #include <string>
23
20
  #include <utility>
24
21
  #include <variant>
@@ -30,9 +27,6 @@
30
27
  #include "envoy/extensions/http/stateful_session/cookie/v3/cookie.upbdefs.h"
31
28
  #include "envoy/type/http/v3/cookie.upb.h"
32
29
  #include "src/core/ext/filters/stateful_session/stateful_session_filter.h"
33
- #include "src/core/lib/channel/channel_args.h"
34
- #include "src/core/util/json/json.h"
35
- #include "src/core/util/json/json_writer.h"
36
30
  #include "src/core/util/time.h"
37
31
  #include "src/core/util/upb_utils.h"
38
32
  #include "src/core/util/validation_errors.h"
@@ -44,17 +38,18 @@
44
38
 
45
39
  namespace grpc_core {
46
40
 
47
- absl::string_view XdsHttpStatefulSessionFilter::ConfigProtoName() const {
41
+ absl::string_view XdsHttpStatefulSessionFilterFactory::ConfigProtoName() const {
48
42
  return "envoy.extensions.filters.http.stateful_session.v3.StatefulSession";
49
43
  }
50
44
 
51
- absl::string_view XdsHttpStatefulSessionFilter::OverrideConfigProtoName()
45
+ absl::string_view XdsHttpStatefulSessionFilterFactory::OverrideConfigProtoName()
52
46
  const {
53
47
  return "envoy.extensions.filters.http.stateful_session.v3"
54
48
  ".StatefulSessionPerRoute";
55
49
  }
56
50
 
57
- void XdsHttpStatefulSessionFilter::PopulateSymtab(upb_DefPool* symtab) const {
51
+ void XdsHttpStatefulSessionFilterFactory::PopulateSymtab(
52
+ upb_DefPool* symtab) const {
58
53
  envoy_extensions_filters_http_stateful_session_v3_StatefulSession_getmsgdef(
59
54
  symtab);
60
55
  envoy_extensions_filters_http_stateful_session_v3_StatefulSessionPerRoute_getmsgdef(
@@ -63,12 +58,12 @@ void XdsHttpStatefulSessionFilter::PopulateSymtab(upb_DefPool* symtab) const {
63
58
  symtab);
64
59
  }
65
60
 
66
- const grpc_channel_filter* XdsHttpStatefulSessionFilter::channel_filter()
61
+ const grpc_channel_filter* XdsHttpStatefulSessionFilterFactory::channel_filter()
67
62
  const {
68
63
  return &StatefulSessionFilter::kFilterVtable;
69
64
  }
70
65
 
71
- void XdsHttpStatefulSessionFilter::AddFilter(
66
+ void XdsHttpStatefulSessionFilterFactory::AddFilter(
72
67
  FilterChainBuilder& builder,
73
68
  RefCountedPtr<const FilterConfig> config) const {
74
69
  builder.AddFilter<StatefulSessionFilter>(std::move(config));
@@ -141,7 +136,7 @@ RefCountedPtr<StatefulSessionFilter::Config> ParseStatefulSession(
141
136
  } // namespace
142
137
 
143
138
  RefCountedPtr<const FilterConfig>
144
- XdsHttpStatefulSessionFilter::ParseTopLevelConfig(
139
+ XdsHttpStatefulSessionFilterFactory::ParseTopLevelConfig(
145
140
  absl::string_view /*instance_name*/,
146
141
  const XdsResourceType::DecodeContext& context,
147
142
  const XdsExtension& extension, ValidationErrors* errors) const {
@@ -163,7 +158,7 @@ XdsHttpStatefulSessionFilter::ParseTopLevelConfig(
163
158
  }
164
159
 
165
160
  RefCountedPtr<const FilterConfig>
166
- XdsHttpStatefulSessionFilter::ParseOverrideConfig(
161
+ XdsHttpStatefulSessionFilterFactory::ParseOverrideConfig(
167
162
  absl::string_view /*instance_name*/,
168
163
  const XdsResourceType::DecodeContext& context,
169
164
  const XdsExtension& extension, ValidationErrors* errors) const {
@@ -17,11 +17,8 @@
17
17
  #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_HTTP_STATEFUL_SESSION_FILTER_H
18
18
  #define GRPC_SRC_CORE_XDS_GRPC_XDS_HTTP_STATEFUL_SESSION_FILTER_H
19
19
 
20
- #include <grpc/support/port_platform.h>
21
-
22
20
  #include <optional>
23
21
 
24
- #include "src/core/lib/channel/channel_args.h"
25
22
  #include "src/core/lib/channel/channel_fwd.h"
26
23
  #include "src/core/util/validation_errors.h"
27
24
  #include "src/core/xds/grpc/xds_common_types.h"
@@ -33,7 +30,7 @@
33
30
 
34
31
  namespace grpc_core {
35
32
 
36
- class XdsHttpStatefulSessionFilter final : public XdsHttpFilterImpl {
33
+ class XdsHttpStatefulSessionFilterFactory final : public XdsHttpFilterFactory {
37
34
  public:
38
35
  absl::string_view ConfigProtoName() const override;
39
36
  absl::string_view OverrideConfigProtoName() const override;