grpc 1.66.0 → 1.67.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (547) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +19 -10
  3. data/include/grpc/credentials.h +1 -1
  4. data/include/grpc/event_engine/README.md +1 -1
  5. data/include/grpc/event_engine/internal/slice_cast.h +1 -1
  6. data/include/grpc/event_engine/slice.h +0 -1
  7. data/include/grpc/event_engine/slice_buffer.h +0 -1
  8. data/include/grpc/grpc_crl_provider.h +1 -1
  9. data/include/grpc/impl/channel_arg_names.h +1 -1
  10. data/include/grpc/support/log.h +34 -32
  11. data/include/grpc/support/sync_generic.h +2 -4
  12. data/src/core/channelz/channelz.cc +0 -1
  13. data/src/core/channelz/channelz_registry.cc +0 -1
  14. data/src/core/client_channel/client_channel.cc +10 -7
  15. data/src/core/client_channel/client_channel.h +1 -1
  16. data/src/core/client_channel/client_channel_filter.cc +21 -18
  17. data/src/core/client_channel/client_channel_filter.h +1 -1
  18. data/src/core/client_channel/client_channel_internal.h +0 -2
  19. data/src/core/client_channel/config_selector.h +0 -1
  20. data/src/core/client_channel/dynamic_filters.cc +0 -2
  21. data/src/core/client_channel/local_subchannel_pool.cc +0 -2
  22. data/src/core/client_channel/retry_filter.h +0 -1
  23. data/src/core/client_channel/retry_filter_legacy_call_data.cc +175 -257
  24. data/src/core/client_channel/subchannel.cc +21 -27
  25. data/src/core/client_channel/subchannel_stream_client.cc +1 -1
  26. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +8 -9
  27. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +0 -1
  28. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +3 -4
  29. data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.cc +167 -0
  30. data/src/core/ext/filters/gcp_authentication/gcp_authentication_filter.h +82 -0
  31. data/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.cc +81 -0
  32. data/src/core/ext/filters/gcp_authentication/gcp_authentication_service_config_parser.h +87 -0
  33. data/src/core/ext/filters/http/message_compress/compression_filter.cc +7 -9
  34. data/src/core/ext/filters/http/server/http_server_filter.cc +2 -4
  35. data/src/core/ext/filters/message_size/message_size_filter.cc +6 -7
  36. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +0 -2
  37. data/src/core/ext/transport/chttp2/alpn/alpn.cc +0 -1
  38. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -8
  39. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +0 -1
  40. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +288 -265
  41. data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -4
  42. data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -1
  43. data/src/core/ext/transport/chttp2/transport/frame.cc +0 -1
  44. data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
  45. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +0 -1
  46. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +6 -6
  47. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +3 -4
  48. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -6
  49. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +0 -1
  50. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -3
  51. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +0 -1
  52. data/src/core/ext/transport/chttp2/transport/hpack_parse_result.h +0 -1
  53. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +3 -3
  54. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +37 -5
  55. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +27 -6
  56. data/src/core/ext/transport/chttp2/transport/internal.h +2 -3
  57. data/src/core/ext/transport/chttp2/transport/parsing.cc +21 -32
  58. data/src/core/ext/transport/chttp2/transport/ping_callbacks.cc +0 -1
  59. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +6 -8
  60. data/src/core/ext/transport/chttp2/transport/varint.h +0 -1
  61. data/src/core/ext/transport/chttp2/transport/write_size_policy.cc +0 -1
  62. data/src/core/ext/transport/chttp2/transport/writing.cc +22 -22
  63. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb.h +431 -0
  64. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.c +129 -0
  65. data/src/core/ext/upb-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upb_minitable.h +33 -0
  66. data/src/core/ext/upb-gen/google/api/expr/v1alpha1/checked.upb.h +16 -0
  67. data/src/core/ext/upb-gen/google/api/expr/v1alpha1/checked.upb_minitable.c +13 -2
  68. data/src/core/ext/upb-gen/google/api/expr/v1alpha1/syntax.upb.h +397 -22
  69. data/src/core/ext/upb-gen/google/api/expr/v1alpha1/syntax.upb_minitable.c +94 -20
  70. data/src/core/ext/upb-gen/google/api/expr/v1alpha1/syntax.upb_minitable.h +2 -0
  71. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.c +86 -0
  72. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/gcp_authn/v3/gcp_authn.upbdefs.h +47 -0
  73. data/src/core/ext/upbdefs-gen/google/api/expr/v1alpha1/checked.upbdefs.c +108 -107
  74. data/src/core/ext/upbdefs-gen/google/api/expr/v1alpha1/syntax.upbdefs.c +101 -78
  75. data/src/core/ext/upbdefs-gen/google/api/expr/v1alpha1/syntax.upbdefs.h +10 -0
  76. data/src/core/handshaker/handshaker.cc +21 -29
  77. data/src/core/handshaker/security/secure_endpoint.cc +3 -3
  78. data/src/core/handshaker/security/security_handshaker.cc +60 -72
  79. data/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +0 -1
  80. data/src/core/lib/backoff/backoff.cc +7 -10
  81. data/src/core/lib/backoff/backoff.h +4 -6
  82. data/src/core/lib/channel/channel_stack.cc +0 -1
  83. data/src/core/lib/channel/channel_stack.h +0 -1
  84. data/src/core/lib/channel/channel_stack_builder_impl.cc +0 -1
  85. data/src/core/lib/channel/connected_channel.cc +0 -1
  86. data/src/core/lib/channel/promise_based_filter.cc +146 -194
  87. data/src/core/lib/channel/promise_based_filter.h +1 -1
  88. data/src/core/lib/compression/compression_internal.cc +0 -1
  89. data/src/core/lib/config/config_vars.cc +11 -1
  90. data/src/core/lib/config/config_vars.h +8 -0
  91. data/src/core/lib/config/core_configuration.cc +0 -1
  92. data/src/core/lib/config/core_configuration.h +0 -1
  93. data/src/core/lib/debug/event_log.cc +0 -1
  94. data/src/core/lib/debug/trace_flags.cc +4 -18
  95. data/src/core/lib/debug/trace_flags.h +2 -5
  96. data/src/core/lib/debug/trace_impl.h +6 -0
  97. data/src/core/lib/event_engine/ares_resolver.cc +89 -56
  98. data/src/core/lib/event_engine/ares_resolver.h +0 -9
  99. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +14 -1
  100. data/src/core/lib/event_engine/cf_engine/cftype_unique_ref.h +1 -1
  101. data/src/core/lib/event_engine/forkable.cc +0 -1
  102. data/src/core/lib/event_engine/forkable.h +0 -1
  103. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +1 -1
  104. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +4 -4
  105. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +0 -1
  106. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +0 -1
  107. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +9 -1
  108. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +0 -1
  109. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +2 -2
  110. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +1 -2
  111. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +4 -9
  112. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +0 -1
  113. data/src/core/lib/event_engine/resolved_address.cc +0 -1
  114. data/src/core/lib/event_engine/slice.cc +0 -1
  115. data/src/core/lib/event_engine/thread_pool/thread_count.cc +0 -1
  116. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +3 -5
  117. data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +121 -93
  118. data/src/core/lib/experiments/config.cc +12 -10
  119. data/src/core/lib/experiments/experiments.cc +45 -66
  120. data/src/core/lib/experiments/experiments.h +22 -27
  121. data/src/core/lib/gprpp/chunked_vector.h +0 -1
  122. data/src/core/lib/gprpp/down_cast.h +0 -1
  123. data/src/core/lib/gprpp/host_port.cc +0 -1
  124. data/src/core/lib/gprpp/load_file.cc +0 -1
  125. data/src/core/lib/gprpp/mpscq.h +0 -1
  126. data/src/core/lib/gprpp/single_set_ptr.h +0 -1
  127. data/src/core/lib/gprpp/status_helper.cc +0 -1
  128. data/src/core/lib/gprpp/sync.h +0 -1
  129. data/src/core/lib/gprpp/table.h +28 -0
  130. data/src/core/lib/gprpp/thd.h +0 -1
  131. data/src/core/lib/gprpp/time.h +0 -1
  132. data/src/core/lib/gprpp/time_util.cc +0 -1
  133. data/src/core/lib/gprpp/windows/directory_reader.cc +0 -2
  134. data/src/core/lib/gprpp/windows/thd.cc +0 -1
  135. data/src/core/lib/gprpp/work_serializer.cc +23 -34
  136. data/src/core/lib/iomgr/buffer_list.cc +0 -1
  137. data/src/core/lib/iomgr/call_combiner.h +6 -8
  138. data/src/core/lib/iomgr/cfstream_handle.cc +6 -8
  139. data/src/core/lib/iomgr/closure.h +5 -8
  140. data/src/core/lib/iomgr/combiner.cc +6 -8
  141. data/src/core/lib/iomgr/endpoint_cfstream.cc +17 -22
  142. data/src/core/lib/iomgr/endpoint_pair_posix.cc +0 -1
  143. data/src/core/lib/iomgr/error.h +0 -1
  144. data/src/core/lib/iomgr/ev_apple.cc +13 -18
  145. data/src/core/lib/iomgr/ev_epoll1_linux.cc +47 -85
  146. data/src/core/lib/iomgr/ev_poll_posix.cc +17 -24
  147. data/src/core/lib/iomgr/ev_posix.cc +55 -44
  148. data/src/core/lib/iomgr/ev_posix.h +0 -5
  149. data/src/core/lib/iomgr/event_engine_shims/closure.cc +7 -9
  150. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +3 -4
  151. data/src/core/lib/iomgr/exec_ctx.cc +6 -9
  152. data/src/core/lib/iomgr/exec_ctx.h +26 -16
  153. data/src/core/lib/iomgr/executor.cc +43 -33
  154. data/src/core/lib/iomgr/fork_windows.cc +0 -1
  155. data/src/core/lib/iomgr/internal_errqueue.cc +0 -1
  156. data/src/core/lib/iomgr/iocp_windows.cc +0 -1
  157. data/src/core/lib/iomgr/iomgr_windows.cc +0 -2
  158. data/src/core/lib/iomgr/lockfree_event.cc +7 -11
  159. data/src/core/lib/iomgr/polling_entity.cc +10 -3
  160. data/src/core/lib/iomgr/pollset_windows.cc +0 -2
  161. data/src/core/lib/iomgr/resolve_address.cc +0 -1
  162. data/src/core/lib/iomgr/resolve_address_posix.cc +0 -1
  163. data/src/core/lib/iomgr/resolve_address_windows.cc +0 -1
  164. data/src/core/lib/iomgr/sockaddr_utils_posix.cc +0 -1
  165. data/src/core/lib/iomgr/socket_mutator.cc +0 -1
  166. data/src/core/lib/iomgr/socket_utils_linux.cc +0 -2
  167. data/src/core/lib/iomgr/socket_utils_posix.cc +0 -1
  168. data/src/core/lib/iomgr/socket_utils_windows.cc +0 -2
  169. data/src/core/lib/iomgr/tcp_client_cfstream.cc +7 -12
  170. data/src/core/lib/iomgr/tcp_client_posix.cc +8 -12
  171. data/src/core/lib/iomgr/tcp_client_windows.cc +0 -1
  172. data/src/core/lib/iomgr/tcp_posix.cc +32 -68
  173. data/src/core/lib/iomgr/tcp_server_posix.cc +7 -11
  174. data/src/core/lib/iomgr/tcp_windows.cc +4 -12
  175. data/src/core/lib/iomgr/timer_generic.cc +46 -65
  176. data/src/core/lib/iomgr/timer_manager.cc +4 -5
  177. data/src/core/lib/iomgr/unix_sockets_posix.cc +0 -1
  178. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +0 -2
  179. data/src/core/lib/iomgr/vsock.cc +0 -1
  180. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
  181. data/src/core/lib/promise/activity.h +0 -1
  182. data/src/core/lib/promise/context.h +0 -1
  183. data/src/core/lib/promise/detail/join_state.h +44 -44
  184. data/src/core/lib/promise/detail/seq_state.h +1101 -1356
  185. data/src/core/lib/promise/for_each.h +8 -15
  186. data/src/core/lib/promise/interceptor_list.h +17 -27
  187. data/src/core/lib/promise/latch.h +16 -24
  188. data/src/core/lib/promise/map.h +1 -1
  189. data/src/core/lib/promise/party.cc +238 -114
  190. data/src/core/lib/promise/party.h +105 -308
  191. data/src/core/lib/promise/pipe.h +3 -4
  192. data/src/core/lib/promise/poll.h +0 -1
  193. data/src/core/lib/promise/status_flag.h +0 -1
  194. data/src/core/lib/resource_quota/connection_quota.cc +0 -1
  195. data/src/core/lib/resource_quota/memory_quota.cc +11 -19
  196. data/src/core/lib/resource_quota/memory_quota.h +2 -4
  197. data/src/core/lib/resource_quota/periodic_update.cc +2 -3
  198. data/src/core/lib/resource_quota/thread_quota.cc +0 -1
  199. data/src/core/lib/security/authorization/audit_logging.cc +0 -1
  200. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +0 -1
  201. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +14 -19
  202. data/src/core/lib/security/authorization/stdout_logger.cc +0 -1
  203. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +0 -1
  204. data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +0 -1
  205. data/src/core/lib/security/credentials/call_creds_util.cc +0 -1
  206. data/src/core/lib/security/credentials/composite/composite_credentials.cc +0 -1
  207. data/src/core/lib/security/credentials/composite/composite_credentials.h +2 -0
  208. data/src/core/lib/security/credentials/credentials.h +1 -2
  209. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +322 -324
  210. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +53 -42
  211. data/src/core/lib/security/credentials/external/external_account_credentials.cc +391 -353
  212. data/src/core/lib/security/credentials/external/external_account_credentials.h +121 -51
  213. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +83 -44
  214. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +27 -7
  215. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +91 -116
  216. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +14 -17
  217. data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -0
  218. data/src/core/lib/security/credentials/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +196 -0
  219. data/src/core/lib/security/credentials/gcp_service_account_identity/gcp_service_account_identity_credentials.h +90 -0
  220. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +27 -41
  221. data/src/core/lib/security/credentials/iam/iam_credentials.cc +0 -1
  222. data/src/core/lib/security/credentials/iam/iam_credentials.h +2 -0
  223. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +2 -0
  224. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +163 -259
  225. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +34 -56
  226. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +12 -16
  227. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
  228. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -1
  229. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +0 -1
  230. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +0 -1
  231. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc +0 -1
  232. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +0 -1
  233. data/src/core/lib/security/credentials/token_fetcher/token_fetcher_credentials.cc +298 -0
  234. data/src/core/lib/security/credentials/token_fetcher/token_fetcher_credentials.h +176 -0
  235. data/src/core/lib/security/credentials/xds/xds_credentials.cc +0 -1
  236. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +0 -1
  237. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +0 -1
  238. data/src/core/lib/security/security_connector/load_system_roots_windows.cc +0 -1
  239. data/src/core/lib/security/transport/server_auth_filter.cc +4 -6
  240. data/src/core/lib/slice/percent_encoding.cc +0 -1
  241. data/src/core/lib/slice/slice.cc +0 -1
  242. data/src/core/lib/slice/slice.h +0 -1
  243. data/src/core/lib/slice/slice_buffer.cc +0 -1
  244. data/src/core/lib/slice/slice_internal.h +0 -1
  245. data/src/core/lib/slice/slice_refcount.h +6 -8
  246. data/src/core/lib/surface/byte_buffer_reader.cc +0 -1
  247. data/src/core/lib/surface/call.cc +3 -5
  248. data/src/core/lib/surface/call_utils.h +0 -1
  249. data/src/core/lib/surface/channel.cc +0 -1
  250. data/src/core/lib/surface/channel_create.cc +0 -1
  251. data/src/core/lib/surface/channel_init.h +0 -1
  252. data/src/core/lib/surface/client_call.cc +0 -1
  253. data/src/core/lib/surface/client_call.h +0 -1
  254. data/src/core/lib/surface/completion_queue.cc +28 -4
  255. data/src/core/lib/surface/completion_queue_factory.cc +0 -1
  256. data/src/core/lib/surface/filter_stack_call.cc +9 -9
  257. data/src/core/lib/surface/filter_stack_call.h +0 -1
  258. data/src/core/lib/surface/lame_client.cc +0 -1
  259. data/src/core/lib/surface/server_call.cc +0 -1
  260. data/src/core/lib/surface/server_call.h +0 -1
  261. data/src/core/lib/surface/validate_metadata.h +0 -1
  262. data/src/core/lib/surface/version.cc +2 -2
  263. data/src/core/lib/transport/bdp_estimator.cc +9 -12
  264. data/src/core/lib/transport/bdp_estimator.h +6 -8
  265. data/src/core/lib/transport/call_arena_allocator.cc +2 -16
  266. data/src/core/lib/transport/call_arena_allocator.h +20 -5
  267. data/src/core/lib/transport/call_filters.cc +6 -9
  268. data/src/core/lib/transport/call_spine.h +24 -13
  269. data/src/core/lib/transport/connectivity_state.cc +34 -42
  270. data/src/core/lib/transport/metadata_batch.h +41 -1
  271. data/src/core/lib/transport/timeout_encoding.cc +0 -1
  272. data/src/core/lib/transport/transport.h +6 -8
  273. data/src/core/lib/transport/transport_op_string.cc +0 -1
  274. data/src/core/lib/uri/uri_parser.cc +0 -1
  275. data/src/core/load_balancing/grpclb/grpclb.cc +55 -71
  276. data/src/core/load_balancing/health_check_client.cc +31 -42
  277. data/src/core/load_balancing/oob_backend_metric.cc +2 -4
  278. data/src/core/load_balancing/outlier_detection/outlier_detection.cc +99 -129
  279. data/src/core/load_balancing/pick_first/pick_first.cc +168 -228
  280. data/src/core/load_balancing/priority/priority.cc +77 -106
  281. data/src/core/load_balancing/ring_hash/ring_hash.cc +32 -46
  282. data/src/core/load_balancing/rls/rls.cc +142 -187
  283. data/src/core/load_balancing/round_robin/round_robin.cc +36 -55
  284. data/src/core/load_balancing/weighted_round_robin/static_stride_scheduler.cc +0 -1
  285. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +85 -110
  286. data/src/core/load_balancing/weighted_target/weighted_target.cc +52 -75
  287. data/src/core/load_balancing/xds/cds.cc +26 -43
  288. data/src/core/load_balancing/xds/xds_cluster_impl.cc +57 -54
  289. data/src/core/load_balancing/xds/xds_cluster_manager.cc +36 -50
  290. data/src/core/load_balancing/xds/xds_override_host.cc +95 -131
  291. data/src/core/load_balancing/xds/xds_wrr_locality.cc +15 -23
  292. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +3 -0
  293. data/src/core/resolver/binder/binder_resolver.cc +0 -2
  294. data/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +62 -44
  295. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +0 -2
  296. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +110 -89
  297. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +132 -96
  298. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +0 -7
  299. data/src/core/resolver/dns/dns_resolver_plugin.cc +0 -1
  300. data/src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +40 -39
  301. data/src/core/resolver/dns/native/dns_resolver.cc +8 -14
  302. data/src/core/resolver/endpoint_addresses.cc +0 -1
  303. data/src/core/resolver/fake/fake_resolver.cc +0 -1
  304. data/src/core/resolver/polling_resolver.cc +6 -15
  305. data/src/core/resolver/polling_resolver.h +1 -1
  306. data/src/core/resolver/xds/xds_config.cc +96 -0
  307. data/src/core/resolver/xds/xds_config.h +109 -0
  308. data/src/core/resolver/xds/xds_dependency_manager.cc +59 -154
  309. data/src/core/resolver/xds/xds_dependency_manager.h +1 -69
  310. data/src/core/resolver/xds/xds_resolver.cc +51 -55
  311. data/src/core/server/server.cc +2 -2
  312. data/src/core/server/server_config_selector_filter.cc +0 -1
  313. data/src/core/server/xds_server_config_fetcher.cc +4 -6
  314. data/src/core/service_config/service_config_call_data.h +2 -3
  315. data/src/core/service_config/service_config_channel_arg_filter.cc +0 -1
  316. data/src/core/service_config/service_config_impl.h +0 -1
  317. data/src/core/telemetry/call_tracer.cc +0 -1
  318. data/src/core/telemetry/metrics.h +0 -1
  319. data/src/core/telemetry/stats_data.cc +67 -0
  320. data/src/core/telemetry/stats_data.h +48 -0
  321. data/src/core/tsi/alts/handshaker/alts_shared_resource.cc +0 -1
  322. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +0 -1
  323. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +0 -1
  324. data/src/core/tsi/fake_transport_security.cc +6 -5
  325. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +0 -1
  326. data/src/core/util/alloc.cc +0 -1
  327. data/src/core/util/gcp_metadata_query.cc +0 -1
  328. data/src/core/util/http_client/httpcli.cc +12 -15
  329. data/src/core/util/http_client/httpcli.h +16 -11
  330. data/src/core/util/http_client/parser.cc +3 -4
  331. data/src/core/util/json/json_reader.cc +0 -1
  332. data/src/core/util/latent_see.cc +29 -9
  333. data/src/core/util/latent_see.h +122 -27
  334. data/src/core/util/log.cc +36 -55
  335. data/src/core/util/lru_cache.h +104 -0
  336. data/src/core/util/msys/tmpfile.cc +0 -1
  337. data/src/core/util/posix/sync.cc +0 -1
  338. data/src/core/util/posix/time.cc +0 -1
  339. data/src/core/util/ring_buffer.h +123 -0
  340. data/src/core/util/spinlock.h +1 -2
  341. data/src/core/util/string.cc +7 -7
  342. data/src/core/util/sync.cc +0 -1
  343. data/src/core/util/sync_abseil.cc +0 -1
  344. data/src/core/util/time.cc +0 -1
  345. data/src/core/util/unique_ptr_with_bitset.h +86 -0
  346. data/src/core/util/useful.h +0 -24
  347. data/src/core/util/windows/cpu.cc +0 -1
  348. data/src/core/util/windows/sync.cc +0 -1
  349. data/src/core/util/windows/time.cc +0 -1
  350. data/src/core/util/windows/tmpfile.cc +0 -1
  351. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +0 -32
  352. data/src/core/xds/grpc/xds_bootstrap_grpc.h +0 -5
  353. data/src/core/xds/grpc/xds_certificate_provider.cc +0 -1
  354. data/src/core/xds/grpc/xds_client_grpc.cc +11 -16
  355. data/src/core/xds/grpc/xds_cluster.cc +2 -8
  356. data/src/core/xds/grpc/xds_cluster.h +4 -4
  357. data/src/core/xds/grpc/xds_cluster_parser.cc +58 -96
  358. data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +0 -1
  359. data/src/core/xds/grpc/xds_common_types_parser.cc +4 -4
  360. data/src/core/xds/grpc/xds_common_types_parser.h +17 -0
  361. data/src/core/xds/grpc/xds_endpoint_parser.cc +14 -14
  362. data/src/core/xds/grpc/xds_http_fault_filter.cc +15 -6
  363. data/src/core/xds/grpc/xds_http_fault_filter.h +5 -1
  364. data/src/core/xds/grpc/xds_http_filter.h +11 -1
  365. data/src/core/xds/grpc/xds_http_filter_registry.cc +7 -1
  366. data/src/core/xds/grpc/xds_http_filter_registry.h +8 -1
  367. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +142 -0
  368. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +61 -0
  369. data/src/core/xds/grpc/xds_http_rbac_filter.cc +14 -6
  370. data/src/core/xds/grpc/xds_http_rbac_filter.h +5 -1
  371. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +9 -1
  372. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +5 -1
  373. data/src/core/xds/grpc/xds_lb_policy_registry.cc +14 -16
  374. data/src/core/xds/grpc/xds_listener_parser.cc +10 -11
  375. data/src/core/xds/grpc/xds_metadata.cc +62 -0
  376. data/src/core/xds/grpc/xds_metadata.h +127 -0
  377. data/src/core/xds/grpc/xds_metadata_parser.cc +143 -0
  378. data/src/core/xds/grpc/xds_metadata_parser.h +36 -0
  379. data/src/core/xds/grpc/xds_route_config_parser.cc +12 -17
  380. data/src/core/xds/grpc/xds_routing.cc +57 -22
  381. data/src/core/xds/grpc/xds_routing.h +10 -2
  382. data/src/core/xds/grpc/xds_transport_grpc.cc +0 -1
  383. data/src/core/xds/xds_client/xds_client.cc +124 -165
  384. data/src/core/xds/xds_client/xds_client_stats.cc +20 -27
  385. data/src/ruby/ext/grpc/rb_call.c +1 -1
  386. data/src/ruby/ext/grpc/rb_call_credentials.c +34 -27
  387. data/src/ruby/ext/grpc/rb_channel.c +22 -16
  388. data/src/ruby/ext/grpc/rb_event_thread.c +3 -2
  389. data/src/ruby/ext/grpc/rb_grpc.c +9 -8
  390. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -10
  391. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +9 -15
  392. data/src/ruby/ext/grpc/rb_server.c +10 -8
  393. data/src/ruby/lib/grpc/generic/active_call.rb +8 -5
  394. data/src/ruby/lib/grpc/version.rb +1 -1
  395. data/src/ruby/spec/call_spec.rb +53 -40
  396. data/src/ruby/spec/channel_spec.rb +4 -2
  397. data/src/ruby/spec/client_server_spec.rb +148 -507
  398. data/src/ruby/spec/generic/active_call_spec.rb +64 -86
  399. data/src/ruby/spec/support/services.rb +3 -0
  400. data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/rand/fork_detect.h → bcm_support.h} +51 -6
  401. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +43 -0
  402. data/third_party/boringssl-with-bazel/src/crypto/cpu_intel.c +72 -23
  403. data/third_party/boringssl-with-bazel/src/crypto/crypto.c +1 -1
  404. data/third_party/boringssl-with-bazel/src/crypto/ecdsa_extra/ecdsa_asn1.c +160 -14
  405. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/internal.h +2 -0
  406. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +79 -78
  407. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm_interface.h +89 -0
  408. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{div.c → div.c.inc} +146 -179
  409. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{random.c → random.c.inc} +6 -8
  410. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{sqrt.c → sqrt.c.inc} +1 -1
  411. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{e_aes.c → e_aes.c.inc} +9 -8
  412. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{ec_key.c → ec_key.c.inc} +11 -7
  413. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256-nistz.c → p256-nistz.c.inc} +104 -12
  414. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-nistz.h +65 -8
  415. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/{ecdsa.c → ecdsa.c.inc} +52 -107
  416. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/internal.h +28 -11
  417. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -80
  418. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/{rand.c → rand.c.inc} +26 -40
  419. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/{padding.c → padding.c.inc} +2 -5
  420. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/{rsa_impl.c → rsa_impl.c.inc} +1 -1
  421. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/{self_check.c → self_check.c.inc} +9 -35
  422. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/internal.h +2 -2
  423. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/{service_indicator.c → service_indicator.c.inc} +2 -2
  424. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +293 -2
  425. data/third_party/boringssl-with-bazel/src/crypto/internal.h +69 -14
  426. data/third_party/boringssl-with-bazel/src/crypto/mem.c +7 -3
  427. data/third_party/boringssl-with-bazel/src/crypto/mldsa/internal.h +73 -0
  428. data/third_party/boringssl-with-bazel/src/crypto/mldsa/mldsa.c +1687 -0
  429. data/third_party/boringssl-with-bazel/src/crypto/mlkem/internal.h +90 -0
  430. data/third_party/boringssl-with-bazel/src/crypto/mlkem/mlkem.cc +1097 -0
  431. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +4 -1
  432. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +4 -5
  433. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c +2 -3
  434. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c +1 -1
  435. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +1 -0
  436. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +9 -1
  437. data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/rand → rand_extra}/fork_detect.c +26 -28
  438. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/getentropy.c +9 -1
  439. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/ios.c +9 -1
  440. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +19 -3
  441. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +26 -23
  442. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/sysrand_internal.h +37 -0
  443. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/trusty.c +9 -1
  444. data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/rand → rand_extra}/urandom.c +19 -19
  445. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +8 -1
  446. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/internal.h +2 -0
  447. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +14 -1
  448. data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +14 -9
  449. data/third_party/boringssl-with-bazel/src/include/openssl/experimental/dilithium.h +13 -15
  450. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +8 -6
  451. data/third_party/boringssl-with-bazel/src/include/openssl/mldsa.h +136 -0
  452. data/third_party/boringssl-with-bazel/src/include/openssl/mlkem.h +246 -0
  453. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +3 -0
  454. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +3 -4
  455. data/third_party/boringssl-with-bazel/src/include/openssl/service_indicator.h +2 -2
  456. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +22 -0
  457. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +35 -5
  458. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +5 -6
  459. data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +6 -0
  460. data/third_party/boringssl-with-bazel/src/ssl/d1_pkt.cc +6 -1
  461. data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +13 -1
  462. data/third_party/boringssl-with-bazel/src/ssl/dtls_record.cc +289 -55
  463. data/third_party/boringssl-with-bazel/src/ssl/extensions.cc +2 -0
  464. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +69 -38
  465. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +14 -3
  466. data/third_party/boringssl-with-bazel/src/ssl/internal.h +107 -14
  467. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +44 -16
  468. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +21 -1
  469. data/third_party/boringssl-with-bazel/src/ssl/ssl_aead_ctx.cc +86 -1
  470. data/third_party/boringssl-with-bazel/src/ssl/ssl_buffer.cc +7 -4
  471. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +97 -3
  472. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +31 -2
  473. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +6 -0
  474. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +18 -4
  475. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +96 -34
  476. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +15 -5
  477. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +3 -23
  478. metadata +113 -87
  479. data/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.cc +0 -45
  480. data/src/core/ext/transport/chttp2/transport/max_concurrent_streams_policy.h +0 -67
  481. data/src/core/util/android/log.cc +0 -48
  482. data/src/core/util/linux/log.cc +0 -69
  483. data/src/core/util/posix/log.cc +0 -69
  484. data/src/core/util/windows/log.cc +0 -73
  485. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/{aes.c → aes.c.inc} +0 -0
  486. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/{aes_nohw.c → aes_nohw.c.inc} +0 -0
  487. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/{key_wrap.c → key_wrap.c.inc} +0 -0
  488. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/{mode_wrappers.c → mode_wrappers.c.inc} +0 -0
  489. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{add.c → add.c.inc} +0 -0
  490. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/asm/{x86_64-gcc.c → x86_64-gcc.c.inc} +0 -0
  491. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{bn.c → bn.c.inc} +0 -0
  492. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{bytes.c → bytes.c.inc} +0 -0
  493. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{cmp.c → cmp.c.inc} +0 -0
  494. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{ctx.c → ctx.c.inc} +0 -0
  495. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{div_extra.c → div_extra.c.inc} +0 -0
  496. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{exponentiation.c → exponentiation.c.inc} +0 -0
  497. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{gcd.c → gcd.c.inc} +0 -0
  498. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{gcd_extra.c → gcd_extra.c.inc} +0 -0
  499. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{generic.c → generic.c.inc} +0 -0
  500. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{jacobi.c → jacobi.c.inc} +0 -0
  501. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{montgomery.c → montgomery.c.inc} +0 -0
  502. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{montgomery_inv.c → montgomery_inv.c.inc} +0 -0
  503. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{mul.c → mul.c.inc} +0 -0
  504. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{prime.c → prime.c.inc} +0 -0
  505. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{rsaz_exp.c → rsaz_exp.c.inc} +0 -0
  506. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/{shift.c → shift.c.inc} +0 -0
  507. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{aead.c → aead.c.inc} +0 -0
  508. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{cipher.c → cipher.c.inc} +0 -0
  509. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/{e_aesccm.c → e_aesccm.c.inc} +0 -0
  510. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cmac/{cmac.c → cmac.c.inc} +0 -0
  511. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/{check.c → check.c.inc} +0 -0
  512. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/{dh.c → dh.c.inc} +0 -0
  513. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/{digest.c → digest.c.inc} +0 -0
  514. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/{digests.c → digests.c.inc} +0 -0
  515. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digestsign/{digestsign.c → digestsign.c.inc} +0 -0
  516. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{ec.c → ec.c.inc} +0 -0
  517. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{ec_montgomery.c → ec_montgomery.c.inc} +0 -0
  518. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{felem.c → felem.c.inc} +0 -0
  519. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{oct.c → oct.c.inc} +0 -0
  520. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p224-64.c → p224-64.c.inc} +0 -0
  521. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{p256.c → p256.c.inc} +0 -0
  522. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{scalar.c → scalar.c.inc} +0 -0
  523. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{simple.c → simple.c.inc} +0 -0
  524. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{simple_mul.c → simple_mul.c.inc} +0 -0
  525. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{util.c → util.c.inc} +0 -0
  526. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/{wnaf.c → wnaf.c.inc} +0 -0
  527. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/{ecdh.c → ecdh.c.inc} +0 -0
  528. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hkdf/{hkdf.c → hkdf.c.inc} +0 -0
  529. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/hmac/{hmac.c → hmac.c.inc} +0 -0
  530. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/{md4.c → md4.c.inc} +0 -0
  531. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/{md5.c → md5.c.inc} +0 -0
  532. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/{cbc.c → cbc.c.inc} +0 -0
  533. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/{cfb.c → cfb.c.inc} +0 -0
  534. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/{ctr.c → ctr.c.inc} +0 -0
  535. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/{gcm.c → gcm.c.inc} +0 -0
  536. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/{gcm_nohw.c → gcm_nohw.c.inc} +0 -0
  537. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/{ofb.c → ofb.c.inc} +0 -0
  538. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/{polyval.c → polyval.c.inc} +0 -0
  539. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/{ctrdrbg.c → ctrdrbg.c.inc} +0 -0
  540. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/{blinding.c → blinding.c.inc} +0 -0
  541. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/{rsa.c → rsa.c.inc} +0 -0
  542. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/{fips.c → fips.c.inc} +0 -0
  543. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/{sha1.c → sha1.c.inc} +0 -0
  544. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/{sha256.c → sha256.c.inc} +0 -0
  545. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/{sha512.c → sha512.c.inc} +0 -0
  546. /data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/tls/{kdf.c → kdf.c.inc} +0 -0
  547. /data/third_party/boringssl-with-bazel/src/crypto/{fipsmodule/rand → rand_extra}/getrandom_fillin.h +0 -0
@@ -69,9 +69,94 @@
69
69
 
70
70
  namespace grpc_core {
71
71
 
72
+ //
73
+ // ExternalAccountCredentials::NoOpFetchBody
74
+ //
75
+
76
+ ExternalAccountCredentials::NoOpFetchBody::NoOpFetchBody(
77
+ grpc_event_engine::experimental::EventEngine& event_engine,
78
+ absl::AnyInvocable<void(absl::StatusOr<std::string>)> on_done,
79
+ absl::StatusOr<std::string> result)
80
+ : FetchBody(std::move(on_done)) {
81
+ event_engine.Run([self = RefAsSubclass<NoOpFetchBody>(),
82
+ result = std::move(result)]() mutable {
83
+ ApplicationCallbackExecCtx application_exec_ctx;
84
+ ExecCtx exec_ctx;
85
+ self->Finish(std::move(result));
86
+ });
87
+ }
88
+
89
+ //
90
+ // ExternalAccountCredentials::HttpFetchBody
91
+ //
92
+
93
+ ExternalAccountCredentials::HttpFetchBody::HttpFetchBody(
94
+ absl::FunctionRef<OrphanablePtr<HttpRequest>(grpc_http_response*,
95
+ grpc_closure*)>
96
+ start_http_request,
97
+ absl::AnyInvocable<void(absl::StatusOr<std::string>)> on_done)
98
+ : FetchBody(std::move(on_done)) {
99
+ GRPC_CLOSURE_INIT(&on_http_response_, OnHttpResponse, this, nullptr);
100
+ Ref().release(); // Ref held by HTTP request callback.
101
+ http_request_ = start_http_request(&response_, &on_http_response_);
102
+ }
103
+
104
+ void ExternalAccountCredentials::HttpFetchBody::OnHttpResponse(
105
+ void* arg, grpc_error_handle error) {
106
+ RefCountedPtr<HttpFetchBody> self(static_cast<HttpFetchBody*>(arg));
107
+ if (!error.ok()) {
108
+ self->Finish(std::move(error));
109
+ return;
110
+ }
111
+ absl::string_view response_body(self->response_.body,
112
+ self->response_.body_length);
113
+ if (self->response_.status != 200) {
114
+ self->Finish(absl::UnavailableError(
115
+ absl::StrCat("Call to HTTP server ended with status ",
116
+ self->response_.status, " [", response_body, "]")));
117
+ return;
118
+ }
119
+ self->Finish(std::string(response_body));
120
+ }
121
+
122
+ //
123
+ // ExternalAccountCredentials::ExternalFetchRequest
124
+ //
125
+
126
+ // The token fetching flow:
127
+ // 1. Retrieve subject token - Subclass's RetrieveSubjectToken() gets called
128
+ // and the subject token is received in ExchangeToken().
129
+ // 2. Exchange token - ExchangeToken() gets called with the
130
+ // subject token from #1.
131
+ // 3. (Optional) Impersonate service account - ImpersonateServiceAccount() gets
132
+ // called with the access token of the response from #2. Get an impersonated
133
+ // access token in OnImpersonateServiceAccountInternal().
134
+ // 4. Finish token fetch - Return back the response that contains an access
135
+ // token in FinishTokenFetch().
136
+ ExternalAccountCredentials::ExternalFetchRequest::ExternalFetchRequest(
137
+ ExternalAccountCredentials* creds, Timestamp deadline,
138
+ absl::AnyInvocable<
139
+ void(absl::StatusOr<RefCountedPtr<TokenFetcherCredentials::Token>>)>
140
+ on_done)
141
+ : creds_(creds), deadline_(deadline), on_done_(std::move(on_done)) {
142
+ fetch_body_ = creds_->RetrieveSubjectToken(
143
+ deadline, [self = RefAsSubclass<ExternalFetchRequest>()](
144
+ absl::StatusOr<std::string> result) {
145
+ self->ExchangeToken(std::move(result));
146
+ });
147
+ }
148
+
149
+ void ExternalAccountCredentials::ExternalFetchRequest::Orphan() {
150
+ {
151
+ MutexLock lock(&mu_);
152
+ fetch_body_.reset();
153
+ }
154
+ Unref();
155
+ }
156
+
72
157
  namespace {
73
158
 
74
- std::string UrlEncode(const absl::string_view& s) {
159
+ std::string UrlEncode(const absl::string_view s) {
75
160
  const char* hex = "0123456789ABCDEF";
76
161
  std::string result;
77
162
  result.reserve(s.length());
@@ -89,6 +174,270 @@ std::string UrlEncode(const absl::string_view& s) {
89
174
  return result;
90
175
  }
91
176
 
177
+ } // namespace
178
+
179
+ void ExternalAccountCredentials::ExternalFetchRequest::ExchangeToken(
180
+ absl::StatusOr<std::string> subject_token) {
181
+ MutexLock lock(&mu_);
182
+ if (MaybeFailLocked(subject_token.status())) return;
183
+ // Parse URI.
184
+ absl::StatusOr<URI> uri = URI::Parse(options().token_url);
185
+ if (!uri.ok()) {
186
+ return FinishTokenFetch(GRPC_ERROR_CREATE(
187
+ absl::StrFormat("Invalid token url: %s. Error: %s", options().token_url,
188
+ uri.status().ToString())));
189
+ }
190
+ // Start HTTP request.
191
+ fetch_body_ = MakeOrphanable<HttpFetchBody>(
192
+ [&](grpc_http_response* response, grpc_closure* on_http_response) {
193
+ grpc_http_request request;
194
+ memset(&request, 0, sizeof(grpc_http_request));
195
+ const bool add_authorization_header =
196
+ !options().client_id.empty() && !options().client_secret.empty();
197
+ request.hdr_count = add_authorization_header ? 3 : 2;
198
+ auto* headers = static_cast<grpc_http_header*>(
199
+ gpr_malloc(sizeof(grpc_http_header) * request.hdr_count));
200
+ headers[0].key = gpr_strdup("Content-Type");
201
+ headers[0].value = gpr_strdup("application/x-www-form-urlencoded");
202
+ headers[1].key = gpr_strdup("x-goog-api-client");
203
+ headers[1].value = gpr_strdup(creds_->MetricsHeaderValue().c_str());
204
+ if (add_authorization_header) {
205
+ std::string raw_cred = absl::StrFormat("%s:%s", options().client_id,
206
+ options().client_secret);
207
+ std::string str =
208
+ absl::StrFormat("Basic %s", absl::Base64Escape(raw_cred));
209
+ headers[2].key = gpr_strdup("Authorization");
210
+ headers[2].value = gpr_strdup(str.c_str());
211
+ }
212
+ request.hdrs = headers;
213
+ std::vector<std::string> body_parts;
214
+ body_parts.push_back(absl::StrFormat(
215
+ "audience=%s", UrlEncode(options().audience).c_str()));
216
+ body_parts.push_back(absl::StrFormat(
217
+ "grant_type=%s",
218
+ UrlEncode(EXTERNAL_ACCOUNT_CREDENTIALS_GRANT_TYPE).c_str()));
219
+ body_parts.push_back(absl::StrFormat(
220
+ "requested_token_type=%s",
221
+ UrlEncode(EXTERNAL_ACCOUNT_CREDENTIALS_REQUESTED_TOKEN_TYPE)
222
+ .c_str()));
223
+ body_parts.push_back(
224
+ absl::StrFormat("subject_token_type=%s",
225
+ UrlEncode(options().subject_token_type).c_str()));
226
+ body_parts.push_back(absl::StrFormat(
227
+ "subject_token=%s", UrlEncode(*subject_token).c_str()));
228
+ std::string scope = GOOGLE_CLOUD_PLATFORM_DEFAULT_SCOPE;
229
+ if (options().service_account_impersonation_url.empty()) {
230
+ scope = absl::StrJoin(creds_->scopes_, " ");
231
+ }
232
+ body_parts.push_back(
233
+ absl::StrFormat("scope=%s", UrlEncode(scope).c_str()));
234
+ Json::Object addtional_options_json_object;
235
+ if (options().client_id.empty() && options().client_secret.empty()) {
236
+ addtional_options_json_object["userProject"] =
237
+ Json::FromString(options().workforce_pool_user_project);
238
+ }
239
+ Json addtional_options_json =
240
+ Json::FromObject(std::move(addtional_options_json_object));
241
+ body_parts.push_back(absl::StrFormat(
242
+ "options=%s", UrlEncode(JsonDump(addtional_options_json)).c_str()));
243
+ std::string body = absl::StrJoin(body_parts, "&");
244
+ request.body = const_cast<char*>(body.c_str());
245
+ request.body_length = body.size();
246
+ RefCountedPtr<grpc_channel_credentials> http_request_creds;
247
+ if (uri->scheme() == "http") {
248
+ http_request_creds = RefCountedPtr<grpc_channel_credentials>(
249
+ grpc_insecure_credentials_create());
250
+ } else {
251
+ http_request_creds = CreateHttpRequestSSLCredentials();
252
+ }
253
+ auto http_request = HttpRequest::Post(
254
+ std::move(*uri), /*args=*/nullptr, pollent(), &request, deadline(),
255
+ on_http_response, response, std::move(http_request_creds));
256
+ http_request->Start();
257
+ request.body = nullptr;
258
+ grpc_http_request_destroy(&request);
259
+ return http_request;
260
+ },
261
+ [self = RefAsSubclass<ExternalFetchRequest>()](
262
+ absl::StatusOr<std::string> result) {
263
+ self->MaybeImpersonateServiceAccount(std::move(result));
264
+ });
265
+ }
266
+
267
+ void ExternalAccountCredentials::ExternalFetchRequest::
268
+ MaybeImpersonateServiceAccount(absl::StatusOr<std::string> response_body) {
269
+ MutexLock lock(&mu_);
270
+ if (MaybeFailLocked(response_body.status())) return;
271
+ // If not doing impersonation, response_body contains oauth token.
272
+ if (options().service_account_impersonation_url.empty()) {
273
+ return FinishTokenFetch(std::move(response_body));
274
+ }
275
+ // Do impersonation.
276
+ auto json = JsonParse(*response_body);
277
+ if (!json.ok()) {
278
+ FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrCat(
279
+ "Invalid token exchange response: ", json.status().ToString())));
280
+ return;
281
+ }
282
+ if (json->type() != Json::Type::kObject) {
283
+ FinishTokenFetch(GRPC_ERROR_CREATE(
284
+ "Invalid token exchange response: JSON type is not object"));
285
+ return;
286
+ }
287
+ auto it = json->object().find("access_token");
288
+ if (it == json->object().end() || it->second.type() != Json::Type::kString) {
289
+ FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
290
+ "Missing or invalid access_token in %s.", *response_body)));
291
+ return;
292
+ }
293
+ absl::string_view access_token = it->second.string();
294
+ absl::StatusOr<URI> uri =
295
+ URI::Parse(options().service_account_impersonation_url);
296
+ if (!uri.ok()) {
297
+ FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
298
+ "Invalid service account impersonation url: %s. Error: %s",
299
+ options().service_account_impersonation_url, uri.status().ToString())));
300
+ return;
301
+ }
302
+ // Start HTTP request.
303
+ fetch_body_ = MakeOrphanable<HttpFetchBody>(
304
+ [&](grpc_http_response* response, grpc_closure* on_http_response) {
305
+ grpc_http_request request;
306
+ memset(&request, 0, sizeof(grpc_http_request));
307
+ request.hdr_count = 2;
308
+ grpc_http_header* headers = static_cast<grpc_http_header*>(
309
+ gpr_malloc(sizeof(grpc_http_header) * request.hdr_count));
310
+ headers[0].key = gpr_strdup("Content-Type");
311
+ headers[0].value = gpr_strdup("application/x-www-form-urlencoded");
312
+ std::string str = absl::StrFormat("Bearer %s", access_token);
313
+ headers[1].key = gpr_strdup("Authorization");
314
+ headers[1].value = gpr_strdup(str.c_str());
315
+ request.hdrs = headers;
316
+ std::vector<std::string> body_members;
317
+ std::string scope = absl::StrJoin(creds_->scopes_, " ");
318
+ body_members.push_back(
319
+ absl::StrFormat("scope=%s", UrlEncode(scope).c_str()));
320
+ body_members.push_back(absl::StrFormat(
321
+ "lifetime=%ds",
322
+ options().service_account_impersonation.token_lifetime_seconds));
323
+ std::string body = absl::StrJoin(body_members, "&");
324
+ request.body = const_cast<char*>(body.c_str());
325
+ request.body_length = body.size();
326
+ // TODO(ctiller): Use the callers resource quota.
327
+ RefCountedPtr<grpc_channel_credentials> http_request_creds;
328
+ if (uri->scheme() == "http") {
329
+ http_request_creds = RefCountedPtr<grpc_channel_credentials>(
330
+ grpc_insecure_credentials_create());
331
+ } else {
332
+ http_request_creds = CreateHttpRequestSSLCredentials();
333
+ }
334
+ auto http_request = HttpRequest::Post(
335
+ std::move(*uri), nullptr, pollent(), &request, deadline(),
336
+ on_http_response, response, std::move(http_request_creds));
337
+ http_request->Start();
338
+ request.body = nullptr;
339
+ grpc_http_request_destroy(&request);
340
+ return http_request;
341
+ },
342
+ [self = RefAsSubclass<ExternalFetchRequest>()](
343
+ absl::StatusOr<std::string> result) {
344
+ self->OnImpersonateServiceAccount(std::move(result));
345
+ });
346
+ }
347
+
348
+ void ExternalAccountCredentials::ExternalFetchRequest::
349
+ OnImpersonateServiceAccount(absl::StatusOr<std::string> response_body) {
350
+ MutexLock lock(&mu_);
351
+ if (MaybeFailLocked(response_body.status())) return;
352
+ auto json = JsonParse(*response_body);
353
+ if (!json.ok()) {
354
+ FinishTokenFetch(GRPC_ERROR_CREATE(
355
+ absl::StrCat("Invalid service account impersonation response: ",
356
+ json.status().ToString())));
357
+ return;
358
+ }
359
+ if (json->type() != Json::Type::kObject) {
360
+ FinishTokenFetch(
361
+ GRPC_ERROR_CREATE("Invalid service account impersonation response: "
362
+ "JSON type is not object"));
363
+ return;
364
+ }
365
+ auto it = json->object().find("accessToken");
366
+ if (it == json->object().end() || it->second.type() != Json::Type::kString) {
367
+ FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
368
+ "Missing or invalid accessToken in %s.", *response_body)));
369
+ return;
370
+ }
371
+ absl::string_view access_token = it->second.string();
372
+ it = json->object().find("expireTime");
373
+ if (it == json->object().end() || it->second.type() != Json::Type::kString) {
374
+ FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
375
+ "Missing or invalid expireTime in %s.", *response_body)));
376
+ return;
377
+ }
378
+ absl::string_view expire_time = it->second.string();
379
+ absl::Time t;
380
+ if (!absl::ParseTime(absl::RFC3339_full, expire_time, &t, nullptr)) {
381
+ FinishTokenFetch(GRPC_ERROR_CREATE(
382
+ "Invalid expire time of service account impersonation response."));
383
+ return;
384
+ }
385
+ int64_t expire_in = (t - absl::Now()) / absl::Seconds(1);
386
+ std::string body = absl::StrFormat(
387
+ "{\"access_token\":\"%s\",\"expires_in\":%d,\"token_type\":\"Bearer\"}",
388
+ access_token, expire_in);
389
+ FinishTokenFetch(std::move(body));
390
+ }
391
+
392
+ void ExternalAccountCredentials::ExternalFetchRequest::FinishTokenFetch(
393
+ absl::StatusOr<std::string> response_body) {
394
+ absl::StatusOr<RefCountedPtr<Token>> result;
395
+ if (!response_body.ok()) {
396
+ LOG(ERROR) << "Fetch external account credentials access token: "
397
+ << response_body.status();
398
+ result = absl::Status(response_body.status().code(),
399
+ absl::StrCat("error fetching oauth2 token: ",
400
+ response_body.status().message()));
401
+ } else {
402
+ absl::optional<Slice> token_value;
403
+ Duration token_lifetime;
404
+ if (grpc_oauth2_token_fetcher_credentials_parse_server_response_body(
405
+ *response_body, &token_value, &token_lifetime) !=
406
+ GRPC_CREDENTIALS_OK) {
407
+ result = GRPC_ERROR_CREATE("Could not parse oauth token");
408
+ } else {
409
+ result = MakeRefCounted<Token>(std::move(*token_value),
410
+ Timestamp::Now() + token_lifetime);
411
+ }
412
+ }
413
+ creds_->event_engine().Run([on_done = std::exchange(on_done_, nullptr),
414
+ result = std::move(result)]() mutable {
415
+ ApplicationCallbackExecCtx application_exec_ctx;
416
+ ExecCtx exec_ctx;
417
+ std::exchange(on_done, nullptr)(std::move(result));
418
+ });
419
+ }
420
+
421
+ bool ExternalAccountCredentials::ExternalFetchRequest::MaybeFailLocked(
422
+ absl::Status status) {
423
+ if (!status.ok()) {
424
+ FinishTokenFetch(std::move(status));
425
+ return true;
426
+ }
427
+ if (fetch_body_ == nullptr) { // Will be set by Orphan() on cancellation.
428
+ FinishTokenFetch(
429
+ absl::CancelledError("external account credentials fetch cancelled"));
430
+ return true;
431
+ }
432
+ return false;
433
+ }
434
+
435
+ //
436
+ // ExternalAccountCredentials
437
+ //
438
+
439
+ namespace {
440
+
92
441
  // Expression to match:
93
442
  // //iam.googleapis.com/locations/[^/]+/workforcePools/[^/]+/providers/.+
94
443
  bool MatchWorkforcePoolAudience(absl::string_view audience) {
@@ -108,49 +457,41 @@ bool MatchWorkforcePoolAudience(absl::string_view audience) {
108
457
 
109
458
  } // namespace
110
459
 
111
- RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create(
460
+ absl::StatusOr<RefCountedPtr<ExternalAccountCredentials>>
461
+ ExternalAccountCredentials::Create(
112
462
  const Json& json, std::vector<std::string> scopes,
113
- grpc_error_handle* error) {
114
- CHECK(error->ok());
463
+ std::shared_ptr<grpc_event_engine::experimental::EventEngine>
464
+ event_engine) {
115
465
  Options options;
116
466
  options.type = GRPC_AUTH_JSON_TYPE_INVALID;
117
467
  if (json.type() != Json::Type::kObject) {
118
- *error =
119
- GRPC_ERROR_CREATE("Invalid json to construct credentials options.");
120
- return nullptr;
468
+ return GRPC_ERROR_CREATE("Invalid json to construct credentials options.");
121
469
  }
122
470
  auto it = json.object().find("type");
123
471
  if (it == json.object().end()) {
124
- *error = GRPC_ERROR_CREATE("type field not present.");
125
- return nullptr;
472
+ return GRPC_ERROR_CREATE("type field not present.");
126
473
  }
127
474
  if (it->second.type() != Json::Type::kString) {
128
- *error = GRPC_ERROR_CREATE("type field must be a string.");
129
- return nullptr;
475
+ return GRPC_ERROR_CREATE("type field must be a string.");
130
476
  }
131
477
  if (it->second.string() != GRPC_AUTH_JSON_TYPE_EXTERNAL_ACCOUNT) {
132
- *error = GRPC_ERROR_CREATE("Invalid credentials json type.");
133
- return nullptr;
478
+ return GRPC_ERROR_CREATE("Invalid credentials json type.");
134
479
  }
135
480
  options.type = GRPC_AUTH_JSON_TYPE_EXTERNAL_ACCOUNT;
136
481
  it = json.object().find("audience");
137
482
  if (it == json.object().end()) {
138
- *error = GRPC_ERROR_CREATE("audience field not present.");
139
- return nullptr;
483
+ return GRPC_ERROR_CREATE("audience field not present.");
140
484
  }
141
485
  if (it->second.type() != Json::Type::kString) {
142
- *error = GRPC_ERROR_CREATE("audience field must be a string.");
143
- return nullptr;
486
+ return GRPC_ERROR_CREATE("audience field must be a string.");
144
487
  }
145
488
  options.audience = it->second.string();
146
489
  it = json.object().find("subject_token_type");
147
490
  if (it == json.object().end()) {
148
- *error = GRPC_ERROR_CREATE("subject_token_type field not present.");
149
- return nullptr;
491
+ return GRPC_ERROR_CREATE("subject_token_type field not present.");
150
492
  }
151
493
  if (it->second.type() != Json::Type::kString) {
152
- *error = GRPC_ERROR_CREATE("subject_token_type field must be a string.");
153
- return nullptr;
494
+ return GRPC_ERROR_CREATE("subject_token_type field must be a string.");
154
495
  }
155
496
  options.subject_token_type = it->second.string();
156
497
  it = json.object().find("service_account_impersonation_url");
@@ -159,12 +500,10 @@ RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create(
159
500
  }
160
501
  it = json.object().find("token_url");
161
502
  if (it == json.object().end()) {
162
- *error = GRPC_ERROR_CREATE("token_url field not present.");
163
- return nullptr;
503
+ return GRPC_ERROR_CREATE("token_url field not present.");
164
504
  }
165
505
  if (it->second.type() != Json::Type::kString) {
166
- *error = GRPC_ERROR_CREATE("token_url field must be a string.");
167
- return nullptr;
506
+ return GRPC_ERROR_CREATE("token_url field must be a string.");
168
507
  }
169
508
  options.token_url = it->second.string();
170
509
  it = json.object().find("token_info_url");
@@ -173,8 +512,7 @@ RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create(
173
512
  }
174
513
  it = json.object().find("credential_source");
175
514
  if (it == json.object().end()) {
176
- *error = GRPC_ERROR_CREATE("credential_source field not present.");
177
- return nullptr;
515
+ return GRPC_ERROR_CREATE("credential_source field not present.");
178
516
  }
179
517
  options.credential_source = it->second;
180
518
  it = json.object().find("quota_project_id");
@@ -194,10 +532,9 @@ RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create(
194
532
  if (MatchWorkforcePoolAudience(options.audience)) {
195
533
  options.workforce_pool_user_project = it->second.string();
196
534
  } else {
197
- *error = GRPC_ERROR_CREATE(
535
+ return GRPC_ERROR_CREATE(
198
536
  "workforce_pool_user_project should not be set for non-workforce "
199
537
  "pool credentials");
200
- return nullptr;
201
538
  }
202
539
  }
203
540
  it = json.object().find("service_account_impersonation");
@@ -211,53 +548,50 @@ RefCountedPtr<ExternalAccountCredentials> ExternalAccountCredentials::Create(
211
548
  if (!absl::SimpleAtoi(
212
549
  service_acc_imp_obj_it->second.string(),
213
550
  &options.service_account_impersonation.token_lifetime_seconds)) {
214
- *error = GRPC_ERROR_CREATE("token_lifetime_seconds must be a number");
215
- return nullptr;
551
+ return GRPC_ERROR_CREATE("token_lifetime_seconds must be a number");
216
552
  }
217
553
  if (options.service_account_impersonation.token_lifetime_seconds >
218
554
  IMPERSONATED_CRED_MAX_LIFETIME_IN_SECONDS) {
219
- *error = GRPC_ERROR_CREATE(
555
+ return GRPC_ERROR_CREATE(
220
556
  absl::StrFormat("token_lifetime_seconds must be less than %ds",
221
557
  IMPERSONATED_CRED_MAX_LIFETIME_IN_SECONDS));
222
- return nullptr;
223
558
  }
224
559
  if (options.service_account_impersonation.token_lifetime_seconds <
225
560
  IMPERSONATED_CRED_MIN_LIFETIME_IN_SECONDS) {
226
- *error = GRPC_ERROR_CREATE(
561
+ return GRPC_ERROR_CREATE(
227
562
  absl::StrFormat("token_lifetime_seconds must be more than %ds",
228
563
  IMPERSONATED_CRED_MIN_LIFETIME_IN_SECONDS));
229
- return nullptr;
230
564
  }
231
565
  }
232
566
  }
233
567
  RefCountedPtr<ExternalAccountCredentials> creds;
568
+ grpc_error_handle error;
234
569
  if (options.credential_source.object().find("environment_id") !=
235
570
  options.credential_source.object().end()) {
236
571
  creds = MakeRefCounted<AwsExternalAccountCredentials>(
237
- std::move(options), std::move(scopes), error);
572
+ std::move(options), std::move(scopes), std::move(event_engine), &error);
238
573
  } else if (options.credential_source.object().find("file") !=
239
574
  options.credential_source.object().end()) {
240
575
  creds = MakeRefCounted<FileExternalAccountCredentials>(
241
- std::move(options), std::move(scopes), error);
576
+ std::move(options), std::move(scopes), std::move(event_engine), &error);
242
577
  } else if (options.credential_source.object().find("url") !=
243
578
  options.credential_source.object().end()) {
244
579
  creds = MakeRefCounted<UrlExternalAccountCredentials>(
245
- std::move(options), std::move(scopes), error);
580
+ std::move(options), std::move(scopes), std::move(event_engine), &error);
246
581
  } else {
247
- *error = GRPC_ERROR_CREATE(
582
+ return GRPC_ERROR_CREATE(
248
583
  "Invalid options credential source to create "
249
584
  "ExternalAccountCredentials.");
250
585
  }
251
- if (error->ok()) {
252
- return creds;
253
- } else {
254
- return nullptr;
255
- }
586
+ if (!error.ok()) return error;
587
+ return creds;
256
588
  }
257
589
 
258
590
  ExternalAccountCredentials::ExternalAccountCredentials(
259
- Options options, std::vector<std::string> scopes)
260
- : options_(std::move(options)) {
591
+ Options options, std::vector<std::string> scopes,
592
+ std::shared_ptr<grpc_event_engine::experimental::EventEngine> event_engine)
593
+ : TokenFetcherCredentials(std::move(event_engine)),
594
+ options_(std::move(options)) {
261
595
  if (scopes.empty()) {
262
596
  scopes.push_back(GOOGLE_CLOUD_PLATFORM_DEFAULT_SCOPE);
263
597
  }
@@ -266,12 +600,6 @@ ExternalAccountCredentials::ExternalAccountCredentials(
266
600
 
267
601
  ExternalAccountCredentials::~ExternalAccountCredentials() {}
268
602
 
269
- std::string ExternalAccountCredentials::debug_string() {
270
- return absl::StrFormat("ExternalAccountCredentials{Audience:%s,%s}",
271
- options_.audience,
272
- grpc_oauth2_token_fetcher_credentials::debug_string());
273
- }
274
-
275
603
  std::string ExternalAccountCredentials::MetricsHeaderValue() {
276
604
  return absl::StrFormat(
277
605
  "gl-cpp/unknown auth/%s google-byoid-sdk source/%s sa-impersonation/%v "
@@ -286,300 +614,12 @@ absl::string_view ExternalAccountCredentials::CredentialSourceType() {
286
614
  return "unknown";
287
615
  }
288
616
 
289
- // The token fetching flow:
290
- // 1. Retrieve subject token - Subclass's RetrieveSubjectToken() gets called
291
- // and the subject token is received in OnRetrieveSubjectTokenInternal().
292
- // 2. Exchange token - ExchangeToken() gets called with the
293
- // subject token from #1. Receive the response in OnExchangeTokenInternal().
294
- // 3. (Optional) Impersonate service account - ImpersenateServiceAccount() gets
295
- // called with the access token of the response from #2. Get an impersonated
296
- // access token in OnImpersenateServiceAccountInternal().
297
- // 4. Finish token fetch - Return back the response that contains an access
298
- // token in FinishTokenFetch().
299
- // TODO(chuanr): Avoid starting the remaining requests if the channel gets shut
300
- // down.
301
- void ExternalAccountCredentials::fetch_oauth2(
302
- grpc_credentials_metadata_request* metadata_req,
303
- grpc_polling_entity* pollent, grpc_iomgr_cb_func response_cb,
304
- Timestamp deadline) {
305
- CHECK_EQ(ctx_, nullptr);
306
- ctx_ = new HTTPRequestContext(pollent, deadline);
307
- metadata_req_ = metadata_req;
308
- response_cb_ = response_cb;
309
- auto cb = [this](std::string token, grpc_error_handle error) {
310
- OnRetrieveSubjectTokenInternal(token, error);
311
- };
312
- RetrieveSubjectToken(ctx_, options_, cb);
313
- }
314
-
315
- void ExternalAccountCredentials::OnRetrieveSubjectTokenInternal(
316
- absl::string_view subject_token, grpc_error_handle error) {
317
- if (!error.ok()) {
318
- FinishTokenFetch(error);
319
- } else {
320
- ExchangeToken(subject_token);
321
- }
322
- }
323
-
324
- void ExternalAccountCredentials::ExchangeToken(
325
- absl::string_view subject_token) {
326
- absl::StatusOr<URI> uri = URI::Parse(options_.token_url);
327
- if (!uri.ok()) {
328
- FinishTokenFetch(GRPC_ERROR_CREATE(
329
- absl::StrFormat("Invalid token url: %s. Error: %s", options_.token_url,
330
- uri.status().ToString())));
331
- return;
332
- }
333
- grpc_http_request request;
334
- memset(&request, 0, sizeof(grpc_http_request));
335
- const bool add_authorization_header =
336
- !options_.client_id.empty() && !options_.client_secret.empty();
337
- request.hdr_count = add_authorization_header ? 3 : 2;
338
- auto* headers = static_cast<grpc_http_header*>(
339
- gpr_malloc(sizeof(grpc_http_header) * request.hdr_count));
340
- headers[0].key = gpr_strdup("Content-Type");
341
- headers[0].value = gpr_strdup("application/x-www-form-urlencoded");
342
- headers[1].key = gpr_strdup("x-goog-api-client");
343
- headers[1].value = gpr_strdup(MetricsHeaderValue().c_str());
344
- if (add_authorization_header) {
345
- std::string raw_cred =
346
- absl::StrFormat("%s:%s", options_.client_id, options_.client_secret);
347
- std::string str = absl::StrFormat("Basic %s", absl::Base64Escape(raw_cred));
348
- headers[2].key = gpr_strdup("Authorization");
349
- headers[2].value = gpr_strdup(str.c_str());
350
- }
351
- request.hdrs = headers;
352
- std::vector<std::string> body_parts;
353
- body_parts.push_back(
354
- absl::StrFormat("audience=%s", UrlEncode(options_.audience).c_str()));
355
- body_parts.push_back(absl::StrFormat(
356
- "grant_type=%s",
357
- UrlEncode(EXTERNAL_ACCOUNT_CREDENTIALS_GRANT_TYPE).c_str()));
358
- body_parts.push_back(absl::StrFormat(
359
- "requested_token_type=%s",
360
- UrlEncode(EXTERNAL_ACCOUNT_CREDENTIALS_REQUESTED_TOKEN_TYPE).c_str()));
361
- body_parts.push_back(absl::StrFormat(
362
- "subject_token_type=%s", UrlEncode(options_.subject_token_type).c_str()));
363
- body_parts.push_back(
364
- absl::StrFormat("subject_token=%s", UrlEncode(subject_token).c_str()));
365
- std::string scope = GOOGLE_CLOUD_PLATFORM_DEFAULT_SCOPE;
366
- if (options_.service_account_impersonation_url.empty()) {
367
- scope = absl::StrJoin(scopes_, " ");
368
- }
369
- body_parts.push_back(absl::StrFormat("scope=%s", UrlEncode(scope).c_str()));
370
- Json::Object addtional_options_json_object;
371
- if (options_.client_id.empty() && options_.client_secret.empty()) {
372
- addtional_options_json_object["userProject"] =
373
- Json::FromString(options_.workforce_pool_user_project);
374
- }
375
- Json addtional_options_json =
376
- Json::FromObject(std::move(addtional_options_json_object));
377
- body_parts.push_back(absl::StrFormat(
378
- "options=%s", UrlEncode(JsonDump(addtional_options_json)).c_str()));
379
- std::string body = absl::StrJoin(body_parts, "&");
380
- request.body = const_cast<char*>(body.c_str());
381
- request.body_length = body.size();
382
- grpc_http_response_destroy(&ctx_->response);
383
- ctx_->response = {};
384
- GRPC_CLOSURE_INIT(&ctx_->closure, OnExchangeToken, this, nullptr);
385
- CHECK(http_request_ == nullptr);
386
- RefCountedPtr<grpc_channel_credentials> http_request_creds;
387
- if (uri->scheme() == "http") {
388
- http_request_creds = RefCountedPtr<grpc_channel_credentials>(
389
- grpc_insecure_credentials_create());
390
- } else {
391
- http_request_creds = CreateHttpRequestSSLCredentials();
392
- }
393
- http_request_ =
394
- HttpRequest::Post(std::move(*uri), nullptr /* channel args */,
395
- ctx_->pollent, &request, ctx_->deadline, &ctx_->closure,
396
- &ctx_->response, std::move(http_request_creds));
397
- http_request_->Start();
398
- request.body = nullptr;
399
- grpc_http_request_destroy(&request);
400
- }
401
-
402
- void ExternalAccountCredentials::OnExchangeToken(void* arg,
403
- grpc_error_handle error) {
404
- ExternalAccountCredentials* self =
405
- static_cast<ExternalAccountCredentials*>(arg);
406
- self->OnExchangeTokenInternal(error);
407
- }
408
-
409
- void ExternalAccountCredentials::OnExchangeTokenInternal(
410
- grpc_error_handle error) {
411
- http_request_.reset();
412
- if (!error.ok()) {
413
- FinishTokenFetch(error);
414
- } else {
415
- if (options_.service_account_impersonation_url.empty()) {
416
- metadata_req_->response = ctx_->response;
417
- metadata_req_->response.body = gpr_strdup(
418
- std::string(ctx_->response.body, ctx_->response.body_length).c_str());
419
- metadata_req_->response.hdrs = static_cast<grpc_http_header*>(
420
- gpr_malloc(sizeof(grpc_http_header) * ctx_->response.hdr_count));
421
- for (size_t i = 0; i < ctx_->response.hdr_count; i++) {
422
- metadata_req_->response.hdrs[i].key =
423
- gpr_strdup(ctx_->response.hdrs[i].key);
424
- metadata_req_->response.hdrs[i].value =
425
- gpr_strdup(ctx_->response.hdrs[i].value);
426
- }
427
- FinishTokenFetch(absl::OkStatus());
428
- } else {
429
- ImpersenateServiceAccount();
430
- }
431
- }
432
- }
433
-
434
- void ExternalAccountCredentials::ImpersenateServiceAccount() {
435
- absl::string_view response_body(ctx_->response.body,
436
- ctx_->response.body_length);
437
- auto json = JsonParse(response_body);
438
- if (!json.ok()) {
439
- FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrCat(
440
- "Invalid token exchange response: ", json.status().ToString())));
441
- return;
442
- }
443
- if (json->type() != Json::Type::kObject) {
444
- FinishTokenFetch(GRPC_ERROR_CREATE(
445
- "Invalid token exchange response: JSON type is not object"));
446
- return;
447
- }
448
- auto it = json->object().find("access_token");
449
- if (it == json->object().end() || it->second.type() != Json::Type::kString) {
450
- FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
451
- "Missing or invalid access_token in %s.", response_body)));
452
- return;
453
- }
454
- std::string access_token = it->second.string();
455
- absl::StatusOr<URI> uri =
456
- URI::Parse(options_.service_account_impersonation_url);
457
- if (!uri.ok()) {
458
- FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
459
- "Invalid service account impersonation url: %s. Error: %s",
460
- options_.service_account_impersonation_url, uri.status().ToString())));
461
- return;
462
- }
463
- grpc_http_request request;
464
- memset(&request, 0, sizeof(grpc_http_request));
465
- request.hdr_count = 2;
466
- grpc_http_header* headers = static_cast<grpc_http_header*>(
467
- gpr_malloc(sizeof(grpc_http_header) * request.hdr_count));
468
- headers[0].key = gpr_strdup("Content-Type");
469
- headers[0].value = gpr_strdup("application/x-www-form-urlencoded");
470
- std::string str = absl::StrFormat("Bearer %s", access_token);
471
- headers[1].key = gpr_strdup("Authorization");
472
- headers[1].value = gpr_strdup(str.c_str());
473
- request.hdrs = headers;
474
- std::vector<std::string> body_members;
475
- std::string scope = absl::StrJoin(scopes_, " ");
476
- body_members.push_back(absl::StrFormat("scope=%s", UrlEncode(scope).c_str()));
477
- body_members.push_back(absl::StrFormat(
478
- "lifetime=%ds",
479
- options_.service_account_impersonation.token_lifetime_seconds));
480
- std::string body = absl::StrJoin(body_members, "&");
481
- request.body = const_cast<char*>(body.c_str());
482
- request.body_length = body.size();
483
- grpc_http_response_destroy(&ctx_->response);
484
- ctx_->response = {};
485
- GRPC_CLOSURE_INIT(&ctx_->closure, OnImpersenateServiceAccount, this, nullptr);
486
- // TODO(ctiller): Use the callers resource quota.
487
- CHECK(http_request_ == nullptr);
488
- RefCountedPtr<grpc_channel_credentials> http_request_creds;
489
- if (uri->scheme() == "http") {
490
- http_request_creds = RefCountedPtr<grpc_channel_credentials>(
491
- grpc_insecure_credentials_create());
492
- } else {
493
- http_request_creds = CreateHttpRequestSSLCredentials();
494
- }
495
- http_request_ = HttpRequest::Post(
496
- std::move(*uri), nullptr, ctx_->pollent, &request, ctx_->deadline,
497
- &ctx_->closure, &ctx_->response, std::move(http_request_creds));
498
- http_request_->Start();
499
- request.body = nullptr;
500
- grpc_http_request_destroy(&request);
501
- }
502
-
503
- void ExternalAccountCredentials::OnImpersenateServiceAccount(
504
- void* arg, grpc_error_handle error) {
505
- ExternalAccountCredentials* self =
506
- static_cast<ExternalAccountCredentials*>(arg);
507
- self->OnImpersenateServiceAccountInternal(error);
508
- }
509
-
510
- void ExternalAccountCredentials::OnImpersenateServiceAccountInternal(
511
- grpc_error_handle error) {
512
- http_request_.reset();
513
- if (!error.ok()) {
514
- FinishTokenFetch(error);
515
- return;
516
- }
517
- absl::string_view response_body(ctx_->response.body,
518
- ctx_->response.body_length);
519
- auto json = JsonParse(response_body);
520
- if (!json.ok()) {
521
- FinishTokenFetch(GRPC_ERROR_CREATE(
522
- absl::StrCat("Invalid service account impersonation response: ",
523
- json.status().ToString())));
524
- return;
525
- }
526
- if (json->type() != Json::Type::kObject) {
527
- FinishTokenFetch(
528
- GRPC_ERROR_CREATE("Invalid service account impersonation response: "
529
- "JSON type is not object"));
530
- return;
531
- }
532
- auto it = json->object().find("accessToken");
533
- if (it == json->object().end() || it->second.type() != Json::Type::kString) {
534
- FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
535
- "Missing or invalid accessToken in %s.", response_body)));
536
- return;
537
- }
538
- std::string access_token = it->second.string();
539
- it = json->object().find("expireTime");
540
- if (it == json->object().end() || it->second.type() != Json::Type::kString) {
541
- FinishTokenFetch(GRPC_ERROR_CREATE(absl::StrFormat(
542
- "Missing or invalid expireTime in %s.", response_body)));
543
- return;
544
- }
545
- std::string expire_time = it->second.string();
546
- absl::Time t;
547
- if (!absl::ParseTime(absl::RFC3339_full, expire_time, &t, nullptr)) {
548
- FinishTokenFetch(GRPC_ERROR_CREATE(
549
- "Invalid expire time of service account impersonation response."));
550
- return;
551
- }
552
- int64_t expire_in = (t - absl::Now()) / absl::Seconds(1);
553
- std::string body = absl::StrFormat(
554
- "{\"access_token\":\"%s\",\"expires_in\":%d,\"token_type\":\"Bearer\"}",
555
- access_token, expire_in);
556
- metadata_req_->response = ctx_->response;
557
- metadata_req_->response.body = gpr_strdup(body.c_str());
558
- metadata_req_->response.body_length = body.length();
559
- metadata_req_->response.hdrs = static_cast<grpc_http_header*>(
560
- gpr_malloc(sizeof(grpc_http_header) * ctx_->response.hdr_count));
561
- for (size_t i = 0; i < ctx_->response.hdr_count; i++) {
562
- metadata_req_->response.hdrs[i].key =
563
- gpr_strdup(ctx_->response.hdrs[i].key);
564
- metadata_req_->response.hdrs[i].value =
565
- gpr_strdup(ctx_->response.hdrs[i].value);
566
- }
567
- FinishTokenFetch(absl::OkStatus());
568
- }
569
-
570
- void ExternalAccountCredentials::FinishTokenFetch(grpc_error_handle error) {
571
- GRPC_LOG_IF_ERROR("Fetch external account credentials access token", error);
572
- // Move object state into local variables.
573
- auto* cb = response_cb_;
574
- response_cb_ = nullptr;
575
- auto* metadata_req = metadata_req_;
576
- metadata_req_ = nullptr;
577
- auto* ctx = ctx_;
578
- ctx_ = nullptr;
579
- // Invoke the callback.
580
- cb(metadata_req, error);
581
- // Delete context.
582
- delete ctx;
617
+ OrphanablePtr<ExternalAccountCredentials::FetchRequest>
618
+ ExternalAccountCredentials::FetchToken(
619
+ Timestamp deadline,
620
+ absl::AnyInvocable<void(absl::StatusOr<RefCountedPtr<Token>>)> on_done) {
621
+ return MakeOrphanable<ExternalFetchRequest>(this, deadline,
622
+ std::move(on_done));
583
623
  }
584
624
 
585
625
  } // namespace grpc_core
@@ -593,14 +633,12 @@ grpc_call_credentials* grpc_external_account_credentials_create(
593
633
  return nullptr;
594
634
  }
595
635
  std::vector<std::string> scopes = absl::StrSplit(scopes_string, ',');
596
- grpc_error_handle error;
597
- auto creds = grpc_core::ExternalAccountCredentials::Create(
598
- *json, std::move(scopes), &error)
599
- .release();
600
- if (!error.ok()) {
636
+ auto creds =
637
+ grpc_core::ExternalAccountCredentials::Create(*json, std::move(scopes));
638
+ if (!creds.ok()) {
601
639
  LOG(ERROR) << "External account credentials creation failed. Error: "
602
- << grpc_core::StatusToString(error);
640
+ << grpc_core::StatusToString(creds.status());
603
641
  return nullptr;
604
642
  }
605
- return creds;
643
+ return creds->release();
606
644
  }