grpc 1.43.1 → 1.44.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +84 -64
- data/include/grpc/grpc_security.h +10 -0
- data/include/grpc/impl/codegen/compression_types.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/client_channel/backend_metric.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +62 -68
- data/src/core/ext/filters/client_channel/client_channel.h +8 -8
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
- data/src/core/ext/filters/client_channel/config_selector.h +4 -4
- data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -14
- data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +3 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +31 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -7
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +43 -29
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +120 -68
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +60 -48
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +62 -61
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -5
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +19 -15
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -12
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +50 -105
- data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
- data/src/core/ext/filters/client_channel/lb_policy.h +19 -3
- data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +207 -81
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +23 -38
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +118 -207
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +25 -32
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +82 -73
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +10 -10
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -5
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +157 -67
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
- data/src/core/ext/filters/client_channel/retry_filter.cc +37 -64
- data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
- data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
- data/src/core/ext/filters/client_channel/subchannel.cc +12 -16
- data/src/core/ext/filters/client_channel/subchannel.h +2 -3
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +37 -48
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -8
- data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +51 -122
- data/src/core/ext/filters/http/client_authority_filter.cc +8 -24
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +42 -140
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
- data/src/core/ext/filters/http/server/http_server_filter.cc +50 -135
- data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
- data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
- data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
- data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -2
- data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +11 -6
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +1 -1
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +89 -29
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +45 -186
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +341 -279
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +69 -159
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +19 -32
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +94 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +2 -24
- data/src/core/ext/transport/chttp2/transport/internal.h +0 -33
- data/src/core/ext/transport/chttp2/transport/parsing.cc +0 -6
- data/src/core/ext/transport/chttp2/transport/writing.cc +47 -116
- data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
- data/src/core/ext/transport/inproc/inproc_transport.cc +11 -63
- data/src/core/ext/transport/inproc/inproc_transport.h +0 -3
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
- data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
- data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
- data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
- data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
- data/src/core/ext/xds/upb_utils.h +65 -0
- data/src/core/ext/xds/xds_api.cc +81 -3458
- data/src/core/ext/xds/xds_api.h +56 -611
- data/src/core/ext/xds/xds_bootstrap.cc +189 -125
- data/src/core/ext/xds/xds_bootstrap.h +20 -15
- data/src/core/ext/xds/xds_certificate_provider.h +1 -0
- data/src/core/ext/xds/xds_channel_creds.cc +108 -0
- data/src/core/ext/xds/xds_channel_creds.h +50 -0
- data/src/core/ext/xds/xds_client.cc +584 -994
- data/src/core/ext/xds/xds_client.h +78 -135
- data/src/core/ext/xds/xds_cluster.cc +451 -0
- data/src/core/ext/xds/xds_cluster.h +111 -0
- data/src/core/ext/xds/xds_common_types.cc +388 -0
- data/src/core/ext/xds/xds_common_types.h +110 -0
- data/src/core/ext/xds/xds_endpoint.cc +364 -0
- data/src/core/ext/xds/xds_endpoint.h +135 -0
- data/src/core/ext/xds/xds_http_filters.cc +5 -0
- data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
- data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
- data/src/core/ext/xds/xds_listener.cc +1036 -0
- data/src/core/ext/xds/xds_listener.h +220 -0
- data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → xds/xds_resource_type.cc} +12 -9
- data/src/core/ext/xds/xds_resource_type.h +98 -0
- data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
- data/src/core/ext/xds/xds_route_config.cc +993 -0
- data/src/core/ext/xds/xds_route_config.h +215 -0
- data/src/core/ext/xds/xds_routing.cc +11 -8
- data/src/core/ext/xds/xds_routing.h +8 -5
- data/src/core/ext/xds/xds_server_config_fetcher.cc +159 -99
- data/src/core/lib/address_utils/parse_address.cc +20 -0
- data/src/core/lib/address_utils/parse_address.h +5 -0
- data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
- data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
- data/src/core/lib/backoff/backoff.cc +4 -30
- data/src/core/lib/backoff/backoff.h +3 -3
- data/src/core/lib/channel/channel_args.cc +0 -1
- data/src/core/lib/channel/channel_stack.cc +8 -0
- data/src/core/lib/channel/channel_stack.h +1 -1
- data/src/core/lib/channel/channel_stack_builder.cc +5 -9
- data/src/core/lib/channel/channel_stack_builder.h +4 -7
- data/src/core/lib/channel/channelz.cc +1 -0
- data/src/core/lib/compression/compression.cc +19 -111
- data/src/core/lib/compression/compression_internal.cc +142 -202
- data/src/core/lib/compression/compression_internal.h +64 -69
- data/src/core/lib/compression/message_compress.cc +11 -11
- data/src/core/lib/compression/message_compress.h +2 -2
- data/src/core/lib/gpr/useful.h +4 -0
- data/src/core/lib/gprpp/bitset.h +7 -0
- data/src/core/lib/gprpp/chunked_vector.h +45 -3
- data/src/core/lib/gprpp/status_helper.cc +20 -28
- data/src/core/lib/gprpp/status_helper.h +6 -19
- data/src/core/lib/gprpp/table.h +11 -0
- data/src/core/lib/http/httpcli.cc +37 -46
- data/src/core/lib/http/httpcli.h +3 -15
- data/src/core/lib/iomgr/call_combiner.cc +15 -4
- data/src/core/lib/iomgr/closure.h +29 -9
- data/src/core/lib/iomgr/combiner.cc +25 -3
- data/src/core/lib/iomgr/error.cc +2 -0
- data/src/core/lib/iomgr/error.h +3 -0
- data/src/core/lib/iomgr/event_engine/iomgr.cc +3 -2
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
- data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
- data/src/core/lib/iomgr/event_engine/resolver.cc +66 -48
- data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
- data/src/core/lib/iomgr/exec_ctx.cc +22 -9
- data/src/core/lib/iomgr/executor.cc +10 -1
- data/src/core/lib/iomgr/fork_posix.cc +3 -2
- data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
- data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
- data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
- data/src/core/lib/iomgr/port.h +2 -2
- data/src/core/lib/iomgr/resolve_address.cc +5 -24
- data/src/core/lib/iomgr/resolve_address.h +47 -44
- data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
- data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
- data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +82 -66
- data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
- data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
- data/src/core/lib/iomgr/resolved_address.h +39 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
- data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
- data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
- data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
- data/src/core/lib/matchers/matchers.cc +1 -1
- data/src/core/lib/promise/activity.h +49 -20
- data/src/core/lib/promise/detail/status.h +5 -0
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +10 -5
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +3 -2
- data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +4 -5
- data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
- data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +4 -4
- data/src/core/lib/resource_quota/api.h +0 -1
- data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
- data/src/core/lib/{gprpp → resource_quota}/arena.h +24 -13
- data/src/core/lib/security/authorization/evaluate_args.cc +30 -15
- data/src/core/lib/security/authorization/evaluate_args.h +1 -0
- data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
- data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
- data/src/core/lib/security/authorization/matchers.cc +227 -0
- data/src/core/lib/security/authorization/matchers.h +211 -0
- data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
- data/src/core/lib/security/authorization/rbac_policy.h +170 -0
- data/src/core/lib/security/context/security_context.cc +4 -2
- data/src/core/lib/security/context/security_context.h +1 -1
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -5
- data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
- data/src/core/lib/security/credentials/credentials.h +10 -20
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +6 -9
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +7 -9
- data/src/core/lib/security/credentials/external/external_account_credentials.h +2 -7
- data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -3
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
- data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -5
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
- data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
- data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +16 -28
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +6 -13
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +44 -57
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -7
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +6 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +7 -0
- data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
- data/src/core/lib/security/security_connector/security_connector.cc +0 -4
- data/src/core/lib/security/security_connector/security_connector.h +5 -1
- data/src/core/lib/security/security_connector/ssl_utils.cc +14 -24
- data/src/core/lib/security/security_connector/ssl_utils.h +5 -14
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +2 -3
- data/src/core/lib/security/transport/auth_filters.h +7 -0
- data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
- data/src/core/lib/security/transport/server_auth_filter.cc +40 -35
- data/src/core/{ext → lib}/service_config/service_config.cc +2 -2
- data/src/core/{ext → lib}/service_config/service_config.h +4 -4
- data/src/core/{ext → lib}/service_config/service_config_call_data.h +5 -5
- data/src/core/{ext → lib}/service_config/service_config_parser.cc +1 -1
- data/src/core/{ext → lib}/service_config/service_config_parser.h +3 -3
- data/src/core/lib/slice/slice.cc +3 -1
- data/src/core/lib/slice/slice.h +43 -13
- data/src/core/lib/slice/slice_intern.cc +3 -101
- data/src/core/lib/slice/slice_internal.h +1 -2
- data/src/core/lib/slice/slice_refcount.h +4 -13
- data/src/core/lib/slice/slice_refcount_base.h +0 -16
- data/src/core/lib/surface/call.cc +140 -382
- data/src/core/lib/surface/call.h +4 -4
- data/src/core/lib/surface/channel.cc +42 -44
- data/src/core/lib/surface/channel.h +4 -4
- data/src/core/lib/surface/init.cc +0 -2
- data/src/core/lib/surface/lame_client.cc +0 -1
- data/src/core/lib/surface/server.cc +12 -29
- data/src/core/lib/surface/server.h +2 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/error_utils.h +14 -0
- data/src/core/lib/transport/metadata_batch.h +799 -717
- data/src/core/lib/transport/parsed_metadata.cc +2 -0
- data/src/core/lib/transport/parsed_metadata.h +95 -92
- data/src/core/lib/transport/timeout_encoding.cc +200 -66
- data/src/core/lib/transport/timeout_encoding.h +40 -10
- data/src/core/lib/transport/transport.h +1 -1
- data/src/core/lib/transport/transport_op_string.cc +6 -39
- data/src/core/lib/uri/uri_parser.cc +223 -53
- data/src/core/lib/uri/uri_parser.h +36 -23
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -5
- data/src/core/tsi/ssl_transport_security.cc +53 -13
- data/src/core/tsi/ssl_transport_security.h +18 -6
- data/src/ruby/ext/grpc/extconf.rb +10 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -1
- data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
- data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
- data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
- data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
- data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
- data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
- data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
- data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
- data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
- data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
- data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
- data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
- data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
- data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
- data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
- data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
- data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
- data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
- data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
- data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
- data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
- data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
- data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
- data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
- data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
- data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
- data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
- data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
- data/third_party/abseil-cpp/absl/random/random.h +189 -0
- data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
- data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
- data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
- data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
- data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
- data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
- data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
- data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
- data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
- data/third_party/boringssl-with-bazel/src/crypto/mem.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
- data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +10 -0
- data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +9 -4
- data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +23 -2
- data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
- data/third_party/xxhash/xxhash.h +607 -352
- metadata +149 -77
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
- data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
- data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
- data/src/core/lib/compression/algorithm_metadata.h +0 -62
- data/src/core/lib/compression/compression_args.cc +0 -140
- data/src/core/lib/compression/compression_args.h +0 -58
- data/src/core/lib/compression/stream_compression.cc +0 -81
- data/src/core/lib/compression/stream_compression.h +0 -117
- data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
- data/src/core/lib/compression/stream_compression_gzip.h +0 -28
- data/src/core/lib/compression/stream_compression_identity.cc +0 -91
- data/src/core/lib/compression/stream_compression_identity.h +0 -29
- data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
- data/src/core/lib/slice/static_slice.cc +0 -377
- data/src/core/lib/slice/static_slice.h +0 -300
- data/src/core/lib/transport/metadata.cc +0 -714
- data/src/core/lib/transport/metadata.h +0 -449
- data/src/core/lib/transport/metadata_batch.cc +0 -99
- data/src/core/lib/transport/static_metadata.cc +0 -1032
- data/src/core/lib/transport/static_metadata.h +0 -322
- data/src/core/lib/transport/status_metadata.cc +0 -63
- data/src/core/lib/transport/status_metadata.h +0 -48
@@ -0,0 +1,605 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2021 gRPC authors.
|
3
|
+
//
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
// you may not use this file except in compliance with the License.
|
6
|
+
// You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
// See the License for the specific language governing permissions and
|
14
|
+
// limitations under the License.
|
15
|
+
//
|
16
|
+
|
17
|
+
#include <grpc/support/port_platform.h>
|
18
|
+
|
19
|
+
#include "src/core/ext/filters/rbac/rbac_service_config_parser.h"
|
20
|
+
|
21
|
+
#include "absl/strings/str_format.h"
|
22
|
+
|
23
|
+
#include "src/core/lib/channel/channel_args.h"
|
24
|
+
#include "src/core/lib/json/json_util.h"
|
25
|
+
#include "src/core/lib/transport/error_utils.h"
|
26
|
+
|
27
|
+
namespace grpc_core {
|
28
|
+
|
29
|
+
namespace {
|
30
|
+
|
31
|
+
size_t g_rbac_parser_index;
|
32
|
+
|
33
|
+
std::string ParseRegexMatcher(const Json::Object& regex_matcher_json,
|
34
|
+
std::vector<grpc_error_handle>* error_list) {
|
35
|
+
std::string regex;
|
36
|
+
ParseJsonObjectField(regex_matcher_json, "regex", ®ex, error_list);
|
37
|
+
return regex;
|
38
|
+
}
|
39
|
+
|
40
|
+
absl::StatusOr<HeaderMatcher> ParseHeaderMatcher(
|
41
|
+
const Json::Object& header_matcher_json,
|
42
|
+
std::vector<grpc_error_handle>* error_list) {
|
43
|
+
std::string name;
|
44
|
+
ParseJsonObjectField(header_matcher_json, "name", &name, error_list);
|
45
|
+
std::string match;
|
46
|
+
HeaderMatcher::Type type = HeaderMatcher::Type();
|
47
|
+
const Json::Object* inner_json;
|
48
|
+
int64_t start = 0;
|
49
|
+
int64_t end = 0;
|
50
|
+
bool present_match = false;
|
51
|
+
bool invert_match = false;
|
52
|
+
ParseJsonObjectField(header_matcher_json, "invertMatch", &invert_match,
|
53
|
+
error_list, /*required=*/false);
|
54
|
+
if (ParseJsonObjectField(header_matcher_json, "exactMatch", &match,
|
55
|
+
error_list, /*required=*/false)) {
|
56
|
+
type = HeaderMatcher::Type::kExact;
|
57
|
+
} else if (ParseJsonObjectField(header_matcher_json, "safeRegexMatch",
|
58
|
+
&inner_json, error_list,
|
59
|
+
/*required=*/false)) {
|
60
|
+
type = HeaderMatcher::Type::kSafeRegex;
|
61
|
+
std::vector<grpc_error_handle> safe_regex_matcher_error_list;
|
62
|
+
match = ParseRegexMatcher(*inner_json, &safe_regex_matcher_error_list);
|
63
|
+
if (!safe_regex_matcher_error_list.empty()) {
|
64
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
|
65
|
+
"safeRegexMatch", &safe_regex_matcher_error_list));
|
66
|
+
}
|
67
|
+
} else if (ParseJsonObjectField(header_matcher_json, "rangeMatch",
|
68
|
+
&inner_json, error_list,
|
69
|
+
/*required=*/false)) {
|
70
|
+
type = HeaderMatcher::Type::kRange;
|
71
|
+
std::vector<grpc_error_handle> range_error_list;
|
72
|
+
ParseJsonObjectField(*inner_json, "start", &start, &range_error_list);
|
73
|
+
ParseJsonObjectField(*inner_json, "end", &end, &range_error_list);
|
74
|
+
if (!range_error_list.empty()) {
|
75
|
+
error_list->push_back(
|
76
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("rangeMatch", &range_error_list));
|
77
|
+
}
|
78
|
+
} else if (ParseJsonObjectField(header_matcher_json, "presentMatch",
|
79
|
+
&present_match, error_list,
|
80
|
+
/*required=*/false)) {
|
81
|
+
type = HeaderMatcher::Type::kPresent;
|
82
|
+
} else if (ParseJsonObjectField(header_matcher_json, "prefixMatch", &match,
|
83
|
+
error_list, /*required=*/false)) {
|
84
|
+
type = HeaderMatcher::Type::kPrefix;
|
85
|
+
} else if (ParseJsonObjectField(header_matcher_json, "suffixMatch", &match,
|
86
|
+
error_list, /*required=*/false)) {
|
87
|
+
type = HeaderMatcher::Type::kSuffix;
|
88
|
+
} else if (ParseJsonObjectField(header_matcher_json, "containsMatch", &match,
|
89
|
+
error_list, /*required=*/false)) {
|
90
|
+
type = HeaderMatcher::Type::kContains;
|
91
|
+
} else {
|
92
|
+
return absl::InvalidArgumentError("No valid matcher found");
|
93
|
+
}
|
94
|
+
return HeaderMatcher::Create(name, type, match, start, end, present_match,
|
95
|
+
invert_match);
|
96
|
+
}
|
97
|
+
|
98
|
+
absl::StatusOr<StringMatcher> ParseStringMatcher(
|
99
|
+
const Json::Object& string_matcher_json,
|
100
|
+
std::vector<grpc_error_handle>* error_list) {
|
101
|
+
std::string match;
|
102
|
+
StringMatcher::Type type = StringMatcher::Type();
|
103
|
+
const Json::Object* inner_json;
|
104
|
+
bool ignore_case = false;
|
105
|
+
ParseJsonObjectField(string_matcher_json, "ignoreCase", &ignore_case,
|
106
|
+
error_list, /*required=*/false);
|
107
|
+
if (ParseJsonObjectField(string_matcher_json, "exact", &match, error_list,
|
108
|
+
/*required=*/false)) {
|
109
|
+
type = StringMatcher::Type::kExact;
|
110
|
+
} else if (ParseJsonObjectField(string_matcher_json, "prefix", &match,
|
111
|
+
error_list, /*required=*/false)) {
|
112
|
+
type = StringMatcher::Type::kPrefix;
|
113
|
+
} else if (ParseJsonObjectField(string_matcher_json, "suffix", &match,
|
114
|
+
error_list, /*required=*/false)) {
|
115
|
+
type = StringMatcher::Type::kSuffix;
|
116
|
+
} else if (ParseJsonObjectField(string_matcher_json, "safeRegex", &inner_json,
|
117
|
+
error_list, /*required=*/false)) {
|
118
|
+
type = StringMatcher::Type::kSafeRegex;
|
119
|
+
std::vector<grpc_error_handle> safe_regex_matcher_error_list;
|
120
|
+
match = ParseRegexMatcher(*inner_json, &safe_regex_matcher_error_list);
|
121
|
+
if (!safe_regex_matcher_error_list.empty()) {
|
122
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
|
123
|
+
"safeRegex", &safe_regex_matcher_error_list));
|
124
|
+
}
|
125
|
+
} else if (ParseJsonObjectField(string_matcher_json, "contains", &match,
|
126
|
+
error_list, /*required=*/false)) {
|
127
|
+
type = StringMatcher::Type::kContains;
|
128
|
+
} else {
|
129
|
+
return absl::InvalidArgumentError("No valid matcher found");
|
130
|
+
}
|
131
|
+
return StringMatcher::Create(type, match, ignore_case);
|
132
|
+
}
|
133
|
+
|
134
|
+
absl::StatusOr<StringMatcher> ParsePathMatcher(
|
135
|
+
const Json::Object& path_matcher_json,
|
136
|
+
std::vector<grpc_error_handle>* error_list) {
|
137
|
+
const Json::Object* string_matcher_json;
|
138
|
+
if (ParseJsonObjectField(path_matcher_json, "path", &string_matcher_json,
|
139
|
+
error_list)) {
|
140
|
+
std::vector<grpc_error_handle> sub_error_list;
|
141
|
+
auto matcher = ParseStringMatcher(*string_matcher_json, &sub_error_list);
|
142
|
+
if (!sub_error_list.empty()) {
|
143
|
+
error_list->push_back(
|
144
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("path", &sub_error_list));
|
145
|
+
}
|
146
|
+
return matcher;
|
147
|
+
}
|
148
|
+
return absl::InvalidArgumentError("No path found");
|
149
|
+
}
|
150
|
+
|
151
|
+
Rbac::CidrRange ParseCidrRange(const Json::Object& cidr_range_json,
|
152
|
+
std::vector<grpc_error_handle>* error_list) {
|
153
|
+
std::string address_prefix;
|
154
|
+
ParseJsonObjectField(cidr_range_json, "addressPrefix", &address_prefix,
|
155
|
+
error_list);
|
156
|
+
const Json::Object* uint32_json;
|
157
|
+
uint32_t prefix_len = 0; // default value
|
158
|
+
if (ParseJsonObjectField(cidr_range_json, "prefixLen", &uint32_json,
|
159
|
+
error_list, /*required=*/false)) {
|
160
|
+
std::vector<grpc_error_handle> sub_error_list;
|
161
|
+
ParseJsonObjectField(*uint32_json, "value", &prefix_len, &sub_error_list);
|
162
|
+
if (!sub_error_list.empty()) {
|
163
|
+
error_list->push_back(
|
164
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("prefixLen", &sub_error_list));
|
165
|
+
}
|
166
|
+
}
|
167
|
+
return Rbac::CidrRange(std::move(address_prefix), prefix_len);
|
168
|
+
}
|
169
|
+
|
170
|
+
Rbac::Permission ParsePermission(const Json::Object& permission_json,
|
171
|
+
std::vector<grpc_error_handle>* error_list) {
|
172
|
+
auto parse_permission_set = [](const Json::Object& permission_set_json,
|
173
|
+
std::vector<grpc_error_handle>* error_list) {
|
174
|
+
const Json::Array* rules_json;
|
175
|
+
std::vector<std::unique_ptr<Rbac::Permission>> permissions;
|
176
|
+
if (ParseJsonObjectField(permission_set_json, "rules", &rules_json,
|
177
|
+
error_list)) {
|
178
|
+
for (size_t i = 0; i < rules_json->size(); ++i) {
|
179
|
+
const Json::Object* permission_json;
|
180
|
+
if (!ExtractJsonType((*rules_json)[i],
|
181
|
+
absl::StrFormat("rules[%d]", i).c_str(),
|
182
|
+
&permission_json, error_list)) {
|
183
|
+
continue;
|
184
|
+
}
|
185
|
+
std::vector<grpc_error_handle> permission_error_list;
|
186
|
+
permissions.emplace_back(absl::make_unique<Rbac::Permission>(
|
187
|
+
ParsePermission(*permission_json, &permission_error_list)));
|
188
|
+
if (!permission_error_list.empty()) {
|
189
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(
|
190
|
+
absl::StrFormat("rules[%d]", i), &permission_error_list));
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
return permissions;
|
195
|
+
};
|
196
|
+
Rbac::Permission permission;
|
197
|
+
const Json::Object* inner_json;
|
198
|
+
bool any;
|
199
|
+
int port;
|
200
|
+
if (ParseJsonObjectField(permission_json, "andRules", &inner_json, error_list,
|
201
|
+
/*required=*/false)) {
|
202
|
+
std::vector<grpc_error_handle> and_rules_error_list;
|
203
|
+
permission = Rbac::Permission::MakeAndPermission(
|
204
|
+
parse_permission_set(*inner_json, &and_rules_error_list));
|
205
|
+
if (!and_rules_error_list.empty()) {
|
206
|
+
error_list->push_back(
|
207
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("andRules", &and_rules_error_list));
|
208
|
+
}
|
209
|
+
} else if (ParseJsonObjectField(permission_json, "orRules", &inner_json,
|
210
|
+
error_list, /*required=*/false)) {
|
211
|
+
std::vector<grpc_error_handle> or_rules_error_list;
|
212
|
+
permission = Rbac::Permission::MakeOrPermission(
|
213
|
+
parse_permission_set(*inner_json, &or_rules_error_list));
|
214
|
+
if (!or_rules_error_list.empty()) {
|
215
|
+
error_list->push_back(
|
216
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("orRules", &or_rules_error_list));
|
217
|
+
}
|
218
|
+
} else if (ParseJsonObjectField(permission_json, "any", &any, error_list,
|
219
|
+
/*required=*/false) &&
|
220
|
+
any) {
|
221
|
+
permission = Rbac::Permission::MakeAnyPermission();
|
222
|
+
} else if (ParseJsonObjectField(permission_json, "header", &inner_json,
|
223
|
+
error_list,
|
224
|
+
/*required=*/false)) {
|
225
|
+
std::vector<grpc_error_handle> header_error_list;
|
226
|
+
auto matcher = ParseHeaderMatcher(*inner_json, &header_error_list);
|
227
|
+
if (matcher.ok()) {
|
228
|
+
permission = Rbac::Permission::MakeHeaderPermission(*matcher);
|
229
|
+
} else {
|
230
|
+
header_error_list.push_back(absl_status_to_grpc_error(matcher.status()));
|
231
|
+
}
|
232
|
+
if (!header_error_list.empty()) {
|
233
|
+
error_list->push_back(
|
234
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("header", &header_error_list));
|
235
|
+
}
|
236
|
+
} else if (ParseJsonObjectField(permission_json, "urlPath", &inner_json,
|
237
|
+
error_list,
|
238
|
+
/*required=*/false)) {
|
239
|
+
std::vector<grpc_error_handle> url_path_error_list;
|
240
|
+
auto matcher = ParsePathMatcher(*inner_json, &url_path_error_list);
|
241
|
+
if (matcher.ok()) {
|
242
|
+
permission = Rbac::Permission::MakePathPermission(*matcher);
|
243
|
+
} else {
|
244
|
+
url_path_error_list.push_back(
|
245
|
+
absl_status_to_grpc_error(matcher.status()));
|
246
|
+
}
|
247
|
+
if (!url_path_error_list.empty()) {
|
248
|
+
error_list->push_back(
|
249
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("urlPath", &url_path_error_list));
|
250
|
+
}
|
251
|
+
} else if (ParseJsonObjectField(permission_json, "destinationIp", &inner_json,
|
252
|
+
error_list, /*required=*/false)) {
|
253
|
+
std::vector<grpc_error_handle> destination_ip_error_list;
|
254
|
+
permission = Rbac::Permission::MakeDestIpPermission(
|
255
|
+
ParseCidrRange(*inner_json, &destination_ip_error_list));
|
256
|
+
if (!destination_ip_error_list.empty()) {
|
257
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
|
258
|
+
"destinationIp", &destination_ip_error_list));
|
259
|
+
}
|
260
|
+
} else if (ParseJsonObjectField(permission_json, "destinationPort", &port,
|
261
|
+
error_list, /*required=*/false)) {
|
262
|
+
permission = Rbac::Permission::MakeDestPortPermission(port);
|
263
|
+
} else if (ParseJsonObjectField(permission_json, "metadata", &inner_json,
|
264
|
+
error_list, /*required=*/false)) {
|
265
|
+
std::vector<grpc_error_handle> metadata_error_list;
|
266
|
+
bool invert = false;
|
267
|
+
ParseJsonObjectField(*inner_json, "invert", &invert, &metadata_error_list,
|
268
|
+
/*required=*/false);
|
269
|
+
if (metadata_error_list.empty()) {
|
270
|
+
permission = Rbac::Permission::MakeMetadataPermission(invert);
|
271
|
+
} else {
|
272
|
+
error_list->push_back(
|
273
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("metadata", &metadata_error_list));
|
274
|
+
}
|
275
|
+
} else if (ParseJsonObjectField(permission_json, "notRule", &inner_json,
|
276
|
+
error_list, /*required=*/false)) {
|
277
|
+
std::vector<grpc_error_handle> not_rule_error_list;
|
278
|
+
permission = Rbac::Permission::MakeNotPermission(
|
279
|
+
ParsePermission(*inner_json, ¬_rule_error_list));
|
280
|
+
if (!not_rule_error_list.empty()) {
|
281
|
+
error_list->push_back(
|
282
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("notRule", ¬_rule_error_list));
|
283
|
+
}
|
284
|
+
} else if (ParseJsonObjectField(permission_json, "requestedServerName",
|
285
|
+
&inner_json, error_list,
|
286
|
+
/*required=*/false)) {
|
287
|
+
std::vector<grpc_error_handle> req_server_name_error_list;
|
288
|
+
auto matcher = ParseStringMatcher(*inner_json, &req_server_name_error_list);
|
289
|
+
if (matcher.ok()) {
|
290
|
+
permission = Rbac::Permission::MakeReqServerNamePermission(*matcher);
|
291
|
+
} else {
|
292
|
+
req_server_name_error_list.push_back(
|
293
|
+
absl_status_to_grpc_error(matcher.status()));
|
294
|
+
}
|
295
|
+
if (!req_server_name_error_list.empty()) {
|
296
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
|
297
|
+
"requestedServerName", &req_server_name_error_list));
|
298
|
+
}
|
299
|
+
} else {
|
300
|
+
error_list->push_back(
|
301
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid rule found"));
|
302
|
+
}
|
303
|
+
return permission;
|
304
|
+
}
|
305
|
+
|
306
|
+
Rbac::Principal ParsePrincipal(const Json::Object& principal_json,
|
307
|
+
std::vector<grpc_error_handle>* error_list) {
|
308
|
+
auto parse_principal_set = [](const Json::Object& principal_set_json,
|
309
|
+
std::vector<grpc_error_handle>* error_list) {
|
310
|
+
const Json::Array* rules_json;
|
311
|
+
std::vector<std::unique_ptr<Rbac::Principal>> principals;
|
312
|
+
if (ParseJsonObjectField(principal_set_json, "ids", &rules_json,
|
313
|
+
error_list)) {
|
314
|
+
for (size_t i = 0; i < rules_json->size(); ++i) {
|
315
|
+
const Json::Object* principal_json;
|
316
|
+
if (!ExtractJsonType((*rules_json)[i],
|
317
|
+
absl::StrFormat("ids[%d]", i).c_str(),
|
318
|
+
&principal_json, error_list)) {
|
319
|
+
continue;
|
320
|
+
}
|
321
|
+
std::vector<grpc_error_handle> principal_error_list;
|
322
|
+
principals.emplace_back(absl::make_unique<Rbac::Principal>(
|
323
|
+
ParsePrincipal(*principal_json, &principal_error_list)));
|
324
|
+
if (!principal_error_list.empty()) {
|
325
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(
|
326
|
+
absl::StrFormat("ids[%d]", i), &principal_error_list));
|
327
|
+
}
|
328
|
+
}
|
329
|
+
}
|
330
|
+
return principals;
|
331
|
+
};
|
332
|
+
Rbac::Principal principal;
|
333
|
+
const Json::Object* inner_json;
|
334
|
+
bool any;
|
335
|
+
if (ParseJsonObjectField(principal_json, "andIds", &inner_json, error_list,
|
336
|
+
/*required=*/false)) {
|
337
|
+
std::vector<grpc_error_handle> and_rules_error_list;
|
338
|
+
principal = Rbac::Principal::MakeAndPrincipal(
|
339
|
+
parse_principal_set(*inner_json, &and_rules_error_list));
|
340
|
+
if (!and_rules_error_list.empty()) {
|
341
|
+
error_list->push_back(
|
342
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("andIds", &and_rules_error_list));
|
343
|
+
}
|
344
|
+
} else if (ParseJsonObjectField(principal_json, "orIds", &inner_json,
|
345
|
+
error_list, /*required=*/false)) {
|
346
|
+
std::vector<grpc_error_handle> or_rules_error_list;
|
347
|
+
principal = Rbac::Principal::MakeOrPrincipal(
|
348
|
+
parse_principal_set(*inner_json, &or_rules_error_list));
|
349
|
+
if (!or_rules_error_list.empty()) {
|
350
|
+
error_list->push_back(
|
351
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("orIds", &or_rules_error_list));
|
352
|
+
}
|
353
|
+
} else if (ParseJsonObjectField(principal_json, "any", &any, error_list,
|
354
|
+
/*required=*/false) &&
|
355
|
+
any) {
|
356
|
+
principal = Rbac::Principal::MakeAnyPrincipal();
|
357
|
+
} else if (ParseJsonObjectField(principal_json, "authenticated", &inner_json,
|
358
|
+
error_list, /*required=*/false)) {
|
359
|
+
std::vector<grpc_error_handle> authenticated_error_list;
|
360
|
+
const Json::Object* principal_name_json;
|
361
|
+
if (ParseJsonObjectField(*inner_json, "principalName", &principal_name_json,
|
362
|
+
&authenticated_error_list, /*required=*/false)) {
|
363
|
+
std::vector<grpc_error_handle> principal_name_error_list;
|
364
|
+
auto matcher =
|
365
|
+
ParseStringMatcher(*principal_name_json, &principal_name_error_list);
|
366
|
+
if (matcher.ok()) {
|
367
|
+
principal = Rbac::Principal::MakeAuthenticatedPrincipal(*matcher);
|
368
|
+
} else {
|
369
|
+
principal_name_error_list.push_back(
|
370
|
+
absl_status_to_grpc_error(matcher.status()));
|
371
|
+
}
|
372
|
+
if (!principal_name_error_list.empty()) {
|
373
|
+
authenticated_error_list.push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
|
374
|
+
"principalName", &principal_name_error_list));
|
375
|
+
}
|
376
|
+
} else if (authenticated_error_list.empty()) {
|
377
|
+
// No principalName found. Match for all users.
|
378
|
+
principal = Rbac::Principal::MakeAnyPrincipal();
|
379
|
+
} else {
|
380
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
|
381
|
+
"authenticated", &authenticated_error_list));
|
382
|
+
}
|
383
|
+
} else if (ParseJsonObjectField(principal_json, "sourceIp", &inner_json,
|
384
|
+
error_list, /*required=*/false)) {
|
385
|
+
std::vector<grpc_error_handle> source_ip_error_list;
|
386
|
+
principal = Rbac::Principal::MakeSourceIpPrincipal(
|
387
|
+
ParseCidrRange(*inner_json, &source_ip_error_list));
|
388
|
+
if (!source_ip_error_list.empty()) {
|
389
|
+
error_list->push_back(
|
390
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("sourceIp", &source_ip_error_list));
|
391
|
+
}
|
392
|
+
} else if (ParseJsonObjectField(principal_json, "directRemoteIp", &inner_json,
|
393
|
+
error_list, /*required=*/false)) {
|
394
|
+
std::vector<grpc_error_handle> direct_remote_ip_error_list;
|
395
|
+
principal = Rbac::Principal::MakeDirectRemoteIpPrincipal(
|
396
|
+
ParseCidrRange(*inner_json, &direct_remote_ip_error_list));
|
397
|
+
if (!direct_remote_ip_error_list.empty()) {
|
398
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR(
|
399
|
+
"directRemoteIp", &direct_remote_ip_error_list));
|
400
|
+
}
|
401
|
+
} else if (ParseJsonObjectField(principal_json, "remoteIp", &inner_json,
|
402
|
+
error_list, /*required=*/false)) {
|
403
|
+
std::vector<grpc_error_handle> remote_ip_error_list;
|
404
|
+
principal = Rbac::Principal::MakeRemoteIpPrincipal(
|
405
|
+
ParseCidrRange(*inner_json, &remote_ip_error_list));
|
406
|
+
if (!remote_ip_error_list.empty()) {
|
407
|
+
error_list->push_back(
|
408
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("remoteIp", &remote_ip_error_list));
|
409
|
+
}
|
410
|
+
} else if (ParseJsonObjectField(principal_json, "header", &inner_json,
|
411
|
+
error_list,
|
412
|
+
/*required=*/false)) {
|
413
|
+
std::vector<grpc_error_handle> header_error_list;
|
414
|
+
auto matcher = ParseHeaderMatcher(*inner_json, &header_error_list);
|
415
|
+
if (matcher.ok()) {
|
416
|
+
principal = Rbac::Principal::MakeHeaderPrincipal(*matcher);
|
417
|
+
} else {
|
418
|
+
header_error_list.push_back(absl_status_to_grpc_error(matcher.status()));
|
419
|
+
}
|
420
|
+
if (!header_error_list.empty()) {
|
421
|
+
error_list->push_back(
|
422
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("header", &header_error_list));
|
423
|
+
}
|
424
|
+
} else if (ParseJsonObjectField(principal_json, "urlPath", &inner_json,
|
425
|
+
error_list,
|
426
|
+
/*required=*/false)) {
|
427
|
+
std::vector<grpc_error_handle> url_path_error_list;
|
428
|
+
auto matcher = ParsePathMatcher(*inner_json, &url_path_error_list);
|
429
|
+
if (matcher.ok()) {
|
430
|
+
principal = Rbac::Principal::MakePathPrincipal(*matcher);
|
431
|
+
} else {
|
432
|
+
url_path_error_list.push_back(
|
433
|
+
absl_status_to_grpc_error(matcher.status()));
|
434
|
+
}
|
435
|
+
if (!url_path_error_list.empty()) {
|
436
|
+
error_list->push_back(
|
437
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("urlPath", &url_path_error_list));
|
438
|
+
}
|
439
|
+
} else if (ParseJsonObjectField(principal_json, "metadata", &inner_json,
|
440
|
+
error_list, /*required=*/false)) {
|
441
|
+
std::vector<grpc_error_handle> metadata_error_list;
|
442
|
+
bool invert = false;
|
443
|
+
ParseJsonObjectField(*inner_json, "invert", &invert, &metadata_error_list,
|
444
|
+
/*required=*/false);
|
445
|
+
if (metadata_error_list.empty()) {
|
446
|
+
principal = Rbac::Principal::MakeMetadataPrincipal(invert);
|
447
|
+
} else {
|
448
|
+
error_list->push_back(
|
449
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("metadata", &metadata_error_list));
|
450
|
+
}
|
451
|
+
} else if (ParseJsonObjectField(principal_json, "notId", &inner_json,
|
452
|
+
error_list, /*required=*/false)) {
|
453
|
+
std::vector<grpc_error_handle> not_rule_error_list;
|
454
|
+
principal = Rbac::Principal::MakeNotPrincipal(
|
455
|
+
ParsePrincipal(*inner_json, ¬_rule_error_list));
|
456
|
+
if (!not_rule_error_list.empty()) {
|
457
|
+
error_list->push_back(
|
458
|
+
GRPC_ERROR_CREATE_FROM_VECTOR("notId", ¬_rule_error_list));
|
459
|
+
}
|
460
|
+
} else {
|
461
|
+
error_list->push_back(
|
462
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid id found"));
|
463
|
+
}
|
464
|
+
return principal;
|
465
|
+
}
|
466
|
+
|
467
|
+
Rbac::Policy ParsePolicy(const Json::Object& policy_json,
|
468
|
+
std::vector<grpc_error_handle>* error_list) {
|
469
|
+
Rbac::Policy policy;
|
470
|
+
const Json::Array* permissions_json_array;
|
471
|
+
std::vector<std::unique_ptr<Rbac::Permission>> permissions;
|
472
|
+
if (ParseJsonObjectField(policy_json, "permissions", &permissions_json_array,
|
473
|
+
error_list)) {
|
474
|
+
for (size_t i = 0; i < permissions_json_array->size(); ++i) {
|
475
|
+
const Json::Object* permission_json;
|
476
|
+
if (!ExtractJsonType((*permissions_json_array)[i],
|
477
|
+
absl::StrFormat("permissions[%d]", i),
|
478
|
+
&permission_json, error_list)) {
|
479
|
+
continue;
|
480
|
+
}
|
481
|
+
std::vector<grpc_error_handle> permission_error_list;
|
482
|
+
permissions.emplace_back(absl::make_unique<Rbac::Permission>(
|
483
|
+
ParsePermission(*permission_json, &permission_error_list)));
|
484
|
+
if (!permission_error_list.empty()) {
|
485
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(
|
486
|
+
absl::StrFormat("permissions[%d]", i), &permission_error_list));
|
487
|
+
}
|
488
|
+
}
|
489
|
+
}
|
490
|
+
const Json::Array* principals_json_array;
|
491
|
+
std::vector<std::unique_ptr<Rbac::Principal>> principals;
|
492
|
+
if (ParseJsonObjectField(policy_json, "principals", &principals_json_array,
|
493
|
+
error_list)) {
|
494
|
+
for (size_t i = 0; i < principals_json_array->size(); ++i) {
|
495
|
+
const Json::Object* principal_json;
|
496
|
+
if (!ExtractJsonType((*principals_json_array)[i],
|
497
|
+
absl::StrFormat("principals[%d]", i),
|
498
|
+
&principal_json, error_list)) {
|
499
|
+
continue;
|
500
|
+
}
|
501
|
+
std::vector<grpc_error_handle> principal_error_list;
|
502
|
+
principals.emplace_back(absl::make_unique<Rbac::Principal>(
|
503
|
+
ParsePrincipal(*principal_json, &principal_error_list)));
|
504
|
+
if (!principal_error_list.empty()) {
|
505
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(
|
506
|
+
absl::StrFormat("principals[%d]", i), &principal_error_list));
|
507
|
+
}
|
508
|
+
}
|
509
|
+
}
|
510
|
+
policy.permissions =
|
511
|
+
Rbac::Permission::MakeOrPermission(std::move(permissions));
|
512
|
+
policy.principals = Rbac::Principal::MakeOrPrincipal(std::move(principals));
|
513
|
+
return policy;
|
514
|
+
}
|
515
|
+
|
516
|
+
Rbac ParseRbac(const Json::Object& rbac_json,
|
517
|
+
std::vector<grpc_error_handle>* error_list) {
|
518
|
+
Rbac rbac;
|
519
|
+
const Json::Object* rules_json;
|
520
|
+
if (!ParseJsonObjectField(rbac_json, "rules", &rules_json, error_list,
|
521
|
+
/*required=*/false)) {
|
522
|
+
// No enforcing to be applied. An empty deny policy with an empty map is
|
523
|
+
// equivalent to no enforcing.
|
524
|
+
return Rbac(Rbac::Action::kDeny, {});
|
525
|
+
}
|
526
|
+
int action;
|
527
|
+
if (ParseJsonObjectField(*rules_json, "action", &action, error_list)) {
|
528
|
+
if (action > 1) {
|
529
|
+
error_list->push_back(
|
530
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unknown action"));
|
531
|
+
}
|
532
|
+
}
|
533
|
+
rbac.action = static_cast<Rbac::Action>(action);
|
534
|
+
const Json::Object* policies_json;
|
535
|
+
if (ParseJsonObjectField(*rules_json, "policies", &policies_json, error_list,
|
536
|
+
/*required=*/false)) {
|
537
|
+
for (const auto& entry : *policies_json) {
|
538
|
+
std::vector<grpc_error_handle> policy_error_list;
|
539
|
+
rbac.policies.emplace(
|
540
|
+
entry.first,
|
541
|
+
ParsePolicy(entry.second.object_value(), &policy_error_list));
|
542
|
+
if (!policy_error_list.empty()) {
|
543
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(
|
544
|
+
absl::StrFormat("policies key:'%s'", entry.first.c_str()),
|
545
|
+
&policy_error_list));
|
546
|
+
}
|
547
|
+
}
|
548
|
+
}
|
549
|
+
return rbac;
|
550
|
+
}
|
551
|
+
|
552
|
+
std::vector<Rbac> ParseRbacArray(const Json::Array& policies_json_array,
|
553
|
+
std::vector<grpc_error_handle>* error_list) {
|
554
|
+
std::vector<Rbac> policies;
|
555
|
+
for (size_t i = 0; i < policies_json_array.size(); ++i) {
|
556
|
+
const Json::Object* rbac_json;
|
557
|
+
if (!ExtractJsonType(policies_json_array[i],
|
558
|
+
absl::StrFormat("rbacPolicy[%d]", i), &rbac_json,
|
559
|
+
error_list)) {
|
560
|
+
continue;
|
561
|
+
}
|
562
|
+
std::vector<grpc_error_handle> rbac_policy_error_list;
|
563
|
+
policies.emplace_back(ParseRbac(*rbac_json, &rbac_policy_error_list));
|
564
|
+
if (!rbac_policy_error_list.empty()) {
|
565
|
+
error_list->push_back(GRPC_ERROR_CREATE_FROM_VECTOR_AND_CPP_STRING(
|
566
|
+
absl::StrFormat("rbacPolicy[%d]", i), &rbac_policy_error_list));
|
567
|
+
}
|
568
|
+
}
|
569
|
+
return policies;
|
570
|
+
}
|
571
|
+
|
572
|
+
} // namespace
|
573
|
+
|
574
|
+
std::unique_ptr<ServiceConfigParser::ParsedConfig>
|
575
|
+
RbacServiceConfigParser::ParsePerMethodParams(const grpc_channel_args* args,
|
576
|
+
const Json& json,
|
577
|
+
grpc_error_handle* error) {
|
578
|
+
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
|
579
|
+
// Only parse rbac policy if the channel arg is present
|
580
|
+
if (!grpc_channel_args_find_bool(args, GRPC_ARG_PARSE_RBAC_METHOD_CONFIG,
|
581
|
+
false)) {
|
582
|
+
return nullptr;
|
583
|
+
}
|
584
|
+
std::vector<Rbac> rbac_policies;
|
585
|
+
std::vector<grpc_error_handle> error_list;
|
586
|
+
const Json::Array* policies_json_array;
|
587
|
+
if (ParseJsonObjectField(json.object_value(), "rbacPolicy",
|
588
|
+
&policies_json_array, &error_list)) {
|
589
|
+
rbac_policies = ParseRbacArray(*policies_json_array, &error_list);
|
590
|
+
}
|
591
|
+
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Rbac parser", &error_list);
|
592
|
+
if (*error != GRPC_ERROR_NONE || rbac_policies.empty()) {
|
593
|
+
return nullptr;
|
594
|
+
}
|
595
|
+
return absl::make_unique<RbacMethodParsedConfig>(std::move(rbac_policies));
|
596
|
+
}
|
597
|
+
|
598
|
+
void RbacServiceConfigParser::Register() {
|
599
|
+
g_rbac_parser_index = ServiceConfigParser::RegisterParser(
|
600
|
+
absl::make_unique<RbacServiceConfigParser>());
|
601
|
+
}
|
602
|
+
|
603
|
+
size_t RbacServiceConfigParser::ParserIndex() { return g_rbac_parser_index; }
|
604
|
+
|
605
|
+
} // namespace grpc_core
|
@@ -0,0 +1,70 @@
|
|
1
|
+
//
|
2
|
+
// Copyright 2021 gRPC authors.
|
3
|
+
//
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
// you may not use this file except in compliance with the License.
|
6
|
+
// You may obtain a copy of the License at
|
7
|
+
//
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
//
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
// See the License for the specific language governing permissions and
|
14
|
+
// limitations under the License.
|
15
|
+
//
|
16
|
+
|
17
|
+
#ifndef GRPC_CORE_EXT_FILTERS_RBAC_RBAC_SERVICE_CONFIG_PARSER_H
|
18
|
+
#define GRPC_CORE_EXT_FILTERS_RBAC_RBAC_SERVICE_CONFIG_PARSER_H
|
19
|
+
|
20
|
+
#include <grpc/support/port_platform.h>
|
21
|
+
|
22
|
+
#include <vector>
|
23
|
+
|
24
|
+
#include "src/core/lib/security/authorization/grpc_authorization_engine.h"
|
25
|
+
#include "src/core/lib/service_config/service_config_parser.h"
|
26
|
+
|
27
|
+
namespace grpc_core {
|
28
|
+
|
29
|
+
// Channel arg key for enabling parsing RBAC via method config.
|
30
|
+
#define GRPC_ARG_PARSE_RBAC_METHOD_CONFIG \
|
31
|
+
"grpc.internal.parse_rbac_method_config"
|
32
|
+
|
33
|
+
class RbacMethodParsedConfig : public ServiceConfigParser::ParsedConfig {
|
34
|
+
public:
|
35
|
+
explicit RbacMethodParsedConfig(std::vector<Rbac> rbac_policies) {
|
36
|
+
for (auto& rbac_policy : rbac_policies) {
|
37
|
+
authorization_engines_.emplace_back(std::move(rbac_policy));
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
// Returns the authorization engine for a rbac policy at a certain index. For
|
42
|
+
// a connection on the server, multiple RBAC policies might be active. The
|
43
|
+
// RBAC filter uses this method to get the RBAC policy configured for a
|
44
|
+
// instance at a particular instance.
|
45
|
+
const GrpcAuthorizationEngine* authorization_engine(int index) const {
|
46
|
+
if (static_cast<size_t>(index) >= authorization_engines_.size()) {
|
47
|
+
return nullptr;
|
48
|
+
}
|
49
|
+
return &authorization_engines_[index];
|
50
|
+
}
|
51
|
+
|
52
|
+
private:
|
53
|
+
std::vector<GrpcAuthorizationEngine> authorization_engines_;
|
54
|
+
};
|
55
|
+
|
56
|
+
class RbacServiceConfigParser : public ServiceConfigParser::Parser {
|
57
|
+
public:
|
58
|
+
// Parses the per-method service config for rbac filter.
|
59
|
+
std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams(
|
60
|
+
const grpc_channel_args* args, const Json& json,
|
61
|
+
grpc_error_handle* error) override;
|
62
|
+
// Returns the parser index for RbacServiceConfigParser.
|
63
|
+
static size_t ParserIndex();
|
64
|
+
// Registers RbacServiceConfigParser to ServiceConfigParser.
|
65
|
+
static void Register();
|
66
|
+
};
|
67
|
+
|
68
|
+
} // namespace grpc_core
|
69
|
+
|
70
|
+
#endif // GRPC_CORE_EXT_FILTERS_RBAC_RBAC_SERVICE_CONFIG_PARSER_H
|