grpc 1.17.1 → 1.18.0.pre1
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 +1228 -988
- data/etc/roots.pem +242 -30
- data/include/grpc/grpc.h +2 -1
- data/include/grpc/grpc_security_constants.h +3 -3
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +2 -0
- data/include/grpc/impl/codegen/compression_types.h +2 -1
- data/include/grpc/impl/codegen/grpc_types.h +1 -1
- data/include/grpc/impl/codegen/port_platform.h +9 -0
- data/src/core/ext/filters/client_channel/client_channel.cc +163 -882
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -4
- data/src/core/ext/filters/client_channel/health/health_check_client.h +2 -3
- data/src/core/ext/filters/client_channel/lb_policy.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy.h +8 -17
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +176 -216
- 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 +20 -23
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +49 -52
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +13 -35
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +31 -30
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +69 -225
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +20 -23
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +2 -84
- data/src/core/ext/filters/client_channel/request_routing.cc +936 -0
- data/src/core/ext/filters/client_channel/request_routing.h +177 -0
- data/src/core/ext/filters/client_channel/resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +37 -26
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +30 -18
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +119 -100
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +8 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +5 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +12 -14
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +5 -9
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -2
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +17 -17
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +45 -52
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +13 -17
- data/src/core/ext/filters/client_channel/server_address.cc +103 -0
- data/src/core/ext/filters/client_channel/server_address.h +108 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +10 -8
- data/src/core/ext/filters/client_channel/subchannel.h +9 -6
- data/src/core/ext/filters/client_channel/subchannel_index.cc +20 -27
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +3 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +8 -9
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -1
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +1 -1
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +8 -11
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +24 -54
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -1
- data/src/core/ext/transport/chttp2/transport/context_list.cc +67 -0
- data/src/core/ext/transport/chttp2/transport/context_list.h +53 -0
- data/src/core/ext/transport/chttp2/transport/internal.h +38 -11
- data/src/core/ext/transport/chttp2/transport/writing.cc +5 -0
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -1
- data/src/core/lib/channel/channelz.cc +19 -18
- data/src/core/lib/channel/channelz.h +7 -1
- data/src/core/lib/channel/channelz_registry.cc +3 -2
- data/src/core/lib/debug/trace.cc +3 -0
- data/src/core/lib/debug/trace.h +5 -3
- data/src/core/lib/gpr/sync_posix.cc +96 -4
- data/src/core/lib/gprpp/inlined_vector.h +25 -19
- data/src/core/lib/gprpp/memory.h +2 -11
- data/src/core/lib/gprpp/orphanable.h +18 -82
- data/src/core/lib/gprpp/ref_counted.h +75 -84
- data/src/core/lib/gprpp/ref_counted_ptr.h +22 -17
- data/src/core/lib/http/httpcli_security_connector.cc +101 -94
- data/src/core/lib/http/parser.h +5 -5
- data/src/core/lib/iomgr/buffer_list.cc +16 -5
- data/src/core/lib/iomgr/buffer_list.h +10 -3
- data/src/core/lib/iomgr/call_combiner.cc +50 -2
- data/src/core/lib/iomgr/call_combiner.h +29 -2
- data/src/core/lib/iomgr/dynamic_annotations.h +67 -0
- data/src/core/lib/iomgr/endpoint.cc +4 -0
- data/src/core/lib/iomgr/endpoint.h +3 -0
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +4 -0
- data/src/core/lib/iomgr/ev_epollex_linux.cc +4 -0
- data/src/core/lib/iomgr/ev_poll_posix.cc +4 -0
- data/src/core/lib/iomgr/ev_posix.cc +15 -7
- data/src/core/lib/iomgr/ev_posix.h +10 -0
- data/src/core/lib/iomgr/exec_ctx.cc +13 -0
- data/src/core/lib/iomgr/fork_posix.cc +1 -1
- data/src/core/lib/iomgr/internal_errqueue.cc +36 -3
- data/src/core/lib/iomgr/internal_errqueue.h +7 -1
- data/src/core/lib/iomgr/iomgr.cc +7 -0
- data/src/core/lib/iomgr/iomgr.h +4 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +3 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +4 -0
- data/src/core/lib/iomgr/iomgr_internal.h +4 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +6 -1
- data/src/core/lib/iomgr/iomgr_windows.cc +4 -1
- data/src/core/lib/iomgr/port.h +1 -2
- data/src/core/lib/iomgr/resource_quota.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils.cc +1 -0
- data/src/core/lib/iomgr/tcp_custom.cc +4 -1
- data/src/core/lib/iomgr/tcp_posix.cc +95 -35
- data/src/core/lib/iomgr/tcp_windows.cc +4 -1
- data/src/core/lib/iomgr/timer_manager.cc +6 -0
- data/src/core/lib/security/context/security_context.cc +75 -108
- data/src/core/lib/security/context/security_context.h +59 -35
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +36 -48
- data/src/core/lib/security/credentials/alts/alts_credentials.h +37 -10
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +97 -157
- data/src/core/lib/security/credentials/composite/composite_credentials.h +60 -24
- data/src/core/lib/security/credentials/credentials.cc +18 -142
- data/src/core/lib/security/credentials/credentials.h +119 -95
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +46 -71
- data/src/core/lib/security/credentials/fake/fake_credentials.h +23 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +144 -51
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +28 -5
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +27 -35
- data/src/core/lib/security/credentials/iam/iam_credentials.h +18 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +60 -69
- data/src/core/lib/security/credentials/jwt/jwt_credentials.h +29 -10
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -0
- data/src/core/lib/security/credentials/local/local_credentials.cc +19 -32
- data/src/core/lib/security/credentials/local/local_credentials.h +32 -11
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +130 -149
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +74 -29
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +59 -77
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +40 -17
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +66 -83
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +58 -15
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +152 -177
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +12 -10
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +210 -215
- data/src/core/lib/security/security_connector/fake/fake_security_connector.h +9 -6
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +176 -169
- data/src/core/lib/security/security_connector/local/local_security_connector.h +10 -9
- data/src/core/lib/security/security_connector/security_connector.cc +41 -124
- data/src/core/lib/security/security_connector/security_connector.h +102 -105
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +348 -370
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +14 -12
- data/src/core/lib/security/security_connector/ssl_utils.cc +13 -9
- data/src/core/lib/security/security_connector/ssl_utils.h +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +50 -50
- data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
- data/src/core/lib/security/transport/security_handshaker.cc +82 -66
- data/src/core/lib/security/transport/server_auth_filter.cc +15 -13
- data/src/core/lib/surface/init.cc +1 -0
- data/src/core/lib/surface/server.cc +13 -11
- data/src/core/lib/surface/server.h +6 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/metadata.cc +1 -0
- data/src/core/lib/transport/static_metadata.cc +228 -221
- data/src/core/lib/transport/static_metadata.h +75 -71
- data/src/core/lib/transport/transport.cc +2 -1
- data/src/core/lib/transport/transport.h +5 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +9 -2
- data/src/core/tsi/ssl_transport_security.cc +35 -24
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +61 -0
- data/src/ruby/lib/grpc/generic/service.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +2 -3
- data/src/ruby/spec/generic/rpc_server_spec.rb +22 -0
- data/src/ruby/spec/support/services.rb +1 -0
- metadata +37 -32
- data/src/core/ext/filters/client_channel/lb_policy_factory.cc +0 -163
@@ -33,40 +33,47 @@
|
|
33
33
|
#define GRPC_CREDENTIALS_TYPE_ALTS "Alts"
|
34
34
|
#define GRPC_ALTS_HANDSHAKER_SERVICE_URL "metadata.google.internal:8080"
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
grpc_alts_credentials_options_destroy(
|
47
|
-
gpr_free(
|
36
|
+
grpc_alts_credentials::grpc_alts_credentials(
|
37
|
+
const grpc_alts_credentials_options* options,
|
38
|
+
const char* handshaker_service_url)
|
39
|
+
: grpc_channel_credentials(GRPC_CREDENTIALS_TYPE_ALTS),
|
40
|
+
options_(grpc_alts_credentials_options_copy(options)),
|
41
|
+
handshaker_service_url_(handshaker_service_url == nullptr
|
42
|
+
? gpr_strdup(GRPC_ALTS_HANDSHAKER_SERVICE_URL)
|
43
|
+
: gpr_strdup(handshaker_service_url)) {}
|
44
|
+
|
45
|
+
grpc_alts_credentials::~grpc_alts_credentials() {
|
46
|
+
grpc_alts_credentials_options_destroy(options_);
|
47
|
+
gpr_free(handshaker_service_url_);
|
48
48
|
}
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
grpc_call_credentials
|
53
|
-
const
|
50
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
51
|
+
grpc_alts_credentials::create_security_connector(
|
52
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
53
|
+
const char* target_name, const grpc_channel_args* args,
|
54
54
|
grpc_channel_args** new_args) {
|
55
55
|
return grpc_alts_channel_security_connector_create(
|
56
|
-
|
56
|
+
this->Ref(), std::move(call_creds), target_name);
|
57
57
|
}
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
grpc_alts_server_credentials::grpc_alts_server_credentials(
|
60
|
+
const grpc_alts_credentials_options* options,
|
61
|
+
const char* handshaker_service_url)
|
62
|
+
: grpc_server_credentials(GRPC_CREDENTIALS_TYPE_ALTS),
|
63
|
+
options_(grpc_alts_credentials_options_copy(options)),
|
64
|
+
handshaker_service_url_(handshaker_service_url == nullptr
|
65
|
+
? gpr_strdup(GRPC_ALTS_HANDSHAKER_SERVICE_URL)
|
66
|
+
: gpr_strdup(handshaker_service_url)) {}
|
67
|
+
|
68
|
+
grpc_core::RefCountedPtr<grpc_server_security_connector>
|
69
|
+
grpc_alts_server_credentials::create_security_connector() {
|
70
|
+
return grpc_alts_server_security_connector_create(this->Ref());
|
62
71
|
}
|
63
72
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
static const grpc_server_credentials_vtable alts_server_credentials_vtable = {
|
69
|
-
alts_server_credentials_destruct, alts_server_create_security_connector};
|
73
|
+
grpc_alts_server_credentials::~grpc_alts_server_credentials() {
|
74
|
+
grpc_alts_credentials_options_destroy(options_);
|
75
|
+
gpr_free(handshaker_service_url_);
|
76
|
+
}
|
70
77
|
|
71
78
|
grpc_channel_credentials* grpc_alts_credentials_create_customized(
|
72
79
|
const grpc_alts_credentials_options* options,
|
@@ -74,17 +81,7 @@ grpc_channel_credentials* grpc_alts_credentials_create_customized(
|
|
74
81
|
if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) {
|
75
82
|
return nullptr;
|
76
83
|
}
|
77
|
-
|
78
|
-
gpr_zalloc(sizeof(grpc_alts_credentials)));
|
79
|
-
creds->options = grpc_alts_credentials_options_copy(options);
|
80
|
-
creds->handshaker_service_url =
|
81
|
-
handshaker_service_url == nullptr
|
82
|
-
? gpr_strdup(GRPC_ALTS_HANDSHAKER_SERVICE_URL)
|
83
|
-
: gpr_strdup(handshaker_service_url);
|
84
|
-
creds->base.type = GRPC_CREDENTIALS_TYPE_ALTS;
|
85
|
-
creds->base.vtable = &alts_credentials_vtable;
|
86
|
-
gpr_ref_init(&creds->base.refcount, 1);
|
87
|
-
return &creds->base;
|
84
|
+
return grpc_core::New<grpc_alts_credentials>(options, handshaker_service_url);
|
88
85
|
}
|
89
86
|
|
90
87
|
grpc_server_credentials* grpc_alts_server_credentials_create_customized(
|
@@ -93,17 +90,8 @@ grpc_server_credentials* grpc_alts_server_credentials_create_customized(
|
|
93
90
|
if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) {
|
94
91
|
return nullptr;
|
95
92
|
}
|
96
|
-
|
97
|
-
|
98
|
-
creds->options = grpc_alts_credentials_options_copy(options);
|
99
|
-
creds->handshaker_service_url =
|
100
|
-
handshaker_service_url == nullptr
|
101
|
-
? gpr_strdup(GRPC_ALTS_HANDSHAKER_SERVICE_URL)
|
102
|
-
: gpr_strdup(handshaker_service_url);
|
103
|
-
creds->base.type = GRPC_CREDENTIALS_TYPE_ALTS;
|
104
|
-
creds->base.vtable = &alts_server_credentials_vtable;
|
105
|
-
gpr_ref_init(&creds->base.refcount, 1);
|
106
|
-
return &creds->base;
|
93
|
+
return grpc_core::New<grpc_alts_server_credentials>(options,
|
94
|
+
handshaker_service_url);
|
107
95
|
}
|
108
96
|
|
109
97
|
grpc_channel_credentials* grpc_alts_credentials_create(
|
@@ -27,18 +27,45 @@
|
|
27
27
|
#include "src/core/lib/security/credentials/credentials.h"
|
28
28
|
|
29
29
|
/* Main struct for grpc ALTS channel credential. */
|
30
|
-
|
31
|
-
|
32
|
-
grpc_alts_credentials_options* options
|
33
|
-
|
34
|
-
|
30
|
+
class grpc_alts_credentials final : public grpc_channel_credentials {
|
31
|
+
public:
|
32
|
+
grpc_alts_credentials(const grpc_alts_credentials_options* options,
|
33
|
+
const char* handshaker_service_url);
|
34
|
+
~grpc_alts_credentials() override;
|
35
|
+
|
36
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
37
|
+
create_security_connector(
|
38
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
39
|
+
const char* target_name, const grpc_channel_args* args,
|
40
|
+
grpc_channel_args** new_args) override;
|
41
|
+
|
42
|
+
const grpc_alts_credentials_options* options() const { return options_; }
|
43
|
+
grpc_alts_credentials_options* mutable_options() { return options_; }
|
44
|
+
const char* handshaker_service_url() const { return handshaker_service_url_; }
|
45
|
+
|
46
|
+
private:
|
47
|
+
grpc_alts_credentials_options* options_;
|
48
|
+
char* handshaker_service_url_;
|
49
|
+
};
|
35
50
|
|
36
51
|
/* Main struct for grpc ALTS server credential. */
|
37
|
-
|
38
|
-
|
39
|
-
grpc_alts_credentials_options* options
|
40
|
-
|
41
|
-
|
52
|
+
class grpc_alts_server_credentials final : public grpc_server_credentials {
|
53
|
+
public:
|
54
|
+
grpc_alts_server_credentials(const grpc_alts_credentials_options* options,
|
55
|
+
const char* handshaker_service_url);
|
56
|
+
~grpc_alts_server_credentials() override;
|
57
|
+
|
58
|
+
grpc_core::RefCountedPtr<grpc_server_security_connector>
|
59
|
+
create_security_connector() override;
|
60
|
+
|
61
|
+
const grpc_alts_credentials_options* options() const { return options_; }
|
62
|
+
grpc_alts_credentials_options* mutable_options() { return options_; }
|
63
|
+
const char* handshaker_service_url() const { return handshaker_service_url_; }
|
64
|
+
|
65
|
+
private:
|
66
|
+
grpc_alts_credentials_options* options_;
|
67
|
+
char* handshaker_service_url_;
|
68
|
+
};
|
42
69
|
|
43
70
|
/**
|
44
71
|
* This method creates an ALTS channel credential object with customized
|
@@ -20,8 +20,10 @@
|
|
20
20
|
|
21
21
|
#include "src/core/lib/security/credentials/composite/composite_credentials.h"
|
22
22
|
|
23
|
-
#include <
|
23
|
+
#include <cstring>
|
24
|
+
#include <new>
|
24
25
|
|
26
|
+
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
25
27
|
#include "src/core/lib/iomgr/polling_entity.h"
|
26
28
|
#include "src/core/lib/surface/api_trace.h"
|
27
29
|
|
@@ -31,35 +33,44 @@
|
|
31
33
|
|
32
34
|
/* -- Composite call credentials. -- */
|
33
35
|
|
34
|
-
|
36
|
+
static void composite_call_metadata_cb(void* arg, grpc_error* error);
|
37
|
+
|
38
|
+
namespace {
|
39
|
+
struct grpc_composite_call_credentials_metadata_context {
|
40
|
+
grpc_composite_call_credentials_metadata_context(
|
41
|
+
grpc_composite_call_credentials* composite_creds,
|
42
|
+
grpc_polling_entity* pollent, grpc_auth_metadata_context auth_md_context,
|
43
|
+
grpc_credentials_mdelem_array* md_array,
|
44
|
+
grpc_closure* on_request_metadata)
|
45
|
+
: composite_creds(composite_creds),
|
46
|
+
pollent(pollent),
|
47
|
+
auth_md_context(auth_md_context),
|
48
|
+
md_array(md_array),
|
49
|
+
on_request_metadata(on_request_metadata) {
|
50
|
+
GRPC_CLOSURE_INIT(&internal_on_request_metadata, composite_call_metadata_cb,
|
51
|
+
this, grpc_schedule_on_exec_ctx);
|
52
|
+
}
|
53
|
+
|
35
54
|
grpc_composite_call_credentials* composite_creds;
|
36
|
-
size_t creds_index;
|
55
|
+
size_t creds_index = 0;
|
37
56
|
grpc_polling_entity* pollent;
|
38
57
|
grpc_auth_metadata_context auth_md_context;
|
39
58
|
grpc_credentials_mdelem_array* md_array;
|
40
59
|
grpc_closure* on_request_metadata;
|
41
60
|
grpc_closure internal_on_request_metadata;
|
42
|
-
}
|
43
|
-
|
44
|
-
static void composite_call_destruct(grpc_call_credentials* creds) {
|
45
|
-
grpc_composite_call_credentials* c =
|
46
|
-
reinterpret_cast<grpc_composite_call_credentials*>(creds);
|
47
|
-
for (size_t i = 0; i < c->inner.num_creds; i++) {
|
48
|
-
grpc_call_credentials_unref(c->inner.creds_array[i]);
|
49
|
-
}
|
50
|
-
gpr_free(c->inner.creds_array);
|
51
|
-
}
|
61
|
+
};
|
62
|
+
} // namespace
|
52
63
|
|
53
64
|
static void composite_call_metadata_cb(void* arg, grpc_error* error) {
|
54
65
|
grpc_composite_call_credentials_metadata_context* ctx =
|
55
66
|
static_cast<grpc_composite_call_credentials_metadata_context*>(arg);
|
56
67
|
if (error == GRPC_ERROR_NONE) {
|
68
|
+
const grpc_composite_call_credentials::CallCredentialsList& inner =
|
69
|
+
ctx->composite_creds->inner();
|
57
70
|
/* See if we need to get some more metadata. */
|
58
|
-
if (ctx->creds_index <
|
59
|
-
|
60
|
-
|
61
|
-
if (grpc_call_credentials_get_request_metadata(
|
62
|
-
inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
|
71
|
+
if (ctx->creds_index < inner.size()) {
|
72
|
+
if (inner[ctx->creds_index++]->get_request_metadata(
|
73
|
+
ctx->pollent, ctx->auth_md_context, ctx->md_array,
|
63
74
|
&ctx->internal_on_request_metadata, &error)) {
|
64
75
|
// Synchronous response, so call ourselves recursively.
|
65
76
|
composite_call_metadata_cb(arg, error);
|
@@ -73,29 +84,18 @@ static void composite_call_metadata_cb(void* arg, grpc_error* error) {
|
|
73
84
|
gpr_free(ctx);
|
74
85
|
}
|
75
86
|
|
76
|
-
|
77
|
-
|
78
|
-
grpc_auth_metadata_context auth_md_context,
|
87
|
+
bool grpc_composite_call_credentials::get_request_metadata(
|
88
|
+
grpc_polling_entity* pollent, grpc_auth_metadata_context auth_md_context,
|
79
89
|
grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
|
80
90
|
grpc_error** error) {
|
81
|
-
grpc_composite_call_credentials* c =
|
82
|
-
reinterpret_cast<grpc_composite_call_credentials*>(creds);
|
83
91
|
grpc_composite_call_credentials_metadata_context* ctx;
|
84
|
-
ctx =
|
85
|
-
|
86
|
-
ctx->composite_creds = c;
|
87
|
-
ctx->pollent = pollent;
|
88
|
-
ctx->auth_md_context = auth_md_context;
|
89
|
-
ctx->md_array = md_array;
|
90
|
-
ctx->on_request_metadata = on_request_metadata;
|
91
|
-
GRPC_CLOSURE_INIT(&ctx->internal_on_request_metadata,
|
92
|
-
composite_call_metadata_cb, ctx, grpc_schedule_on_exec_ctx);
|
92
|
+
ctx = grpc_core::New<grpc_composite_call_credentials_metadata_context>(
|
93
|
+
this, pollent, auth_md_context, md_array, on_request_metadata);
|
93
94
|
bool synchronous = true;
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
|
95
|
+
const CallCredentialsList& inner = ctx->composite_creds->inner();
|
96
|
+
while (ctx->creds_index < inner.size()) {
|
97
|
+
if (inner[ctx->creds_index++]->get_request_metadata(
|
98
|
+
ctx->pollent, ctx->auth_md_context, ctx->md_array,
|
99
99
|
&ctx->internal_on_request_metadata, error)) {
|
100
100
|
if (*error != GRPC_ERROR_NONE) break;
|
101
101
|
} else {
|
@@ -103,46 +103,66 @@ static bool composite_call_get_request_metadata(
|
|
103
103
|
break;
|
104
104
|
}
|
105
105
|
}
|
106
|
-
if (synchronous)
|
106
|
+
if (synchronous) grpc_core::Delete(ctx);
|
107
107
|
return synchronous;
|
108
108
|
}
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
reinterpret_cast<grpc_composite_call_credentials*>(creds);
|
115
|
-
for (size_t i = 0; i < c->inner.num_creds; ++i) {
|
116
|
-
grpc_call_credentials_cancel_get_request_metadata(
|
117
|
-
c->inner.creds_array[i], md_array, GRPC_ERROR_REF(error));
|
110
|
+
void grpc_composite_call_credentials::cancel_get_request_metadata(
|
111
|
+
grpc_credentials_mdelem_array* md_array, grpc_error* error) {
|
112
|
+
for (size_t i = 0; i < inner_.size(); ++i) {
|
113
|
+
inner_[i]->cancel_get_request_metadata(md_array, GRPC_ERROR_REF(error));
|
118
114
|
}
|
119
115
|
GRPC_ERROR_UNREF(error);
|
120
116
|
}
|
121
117
|
|
122
|
-
static
|
123
|
-
|
124
|
-
|
118
|
+
static size_t get_creds_array_size(const grpc_call_credentials* creds,
|
119
|
+
bool is_composite) {
|
120
|
+
return is_composite
|
121
|
+
? static_cast<const grpc_composite_call_credentials*>(creds)
|
122
|
+
->inner()
|
123
|
+
.size()
|
124
|
+
: 1;
|
125
|
+
}
|
125
126
|
|
126
|
-
|
127
|
-
grpc_call_credentials
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
127
|
+
void grpc_composite_call_credentials::push_to_inner(
|
128
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds, bool is_composite) {
|
129
|
+
if (!is_composite) {
|
130
|
+
inner_.push_back(std::move(creds));
|
131
|
+
return;
|
132
|
+
}
|
133
|
+
auto composite_creds =
|
134
|
+
static_cast<grpc_composite_call_credentials*>(creds.get());
|
135
|
+
for (size_t i = 0; i < composite_creds->inner().size(); ++i) {
|
136
|
+
inner_.push_back(std::move(composite_creds->inner_[i]));
|
134
137
|
}
|
135
|
-
|
138
|
+
}
|
139
|
+
|
140
|
+
grpc_composite_call_credentials::grpc_composite_call_credentials(
|
141
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds1,
|
142
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds2)
|
143
|
+
: grpc_call_credentials(GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) {
|
144
|
+
const bool creds1_is_composite =
|
145
|
+
strcmp(creds1->type(), GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0;
|
146
|
+
const bool creds2_is_composite =
|
147
|
+
strcmp(creds2->type(), GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0;
|
148
|
+
const size_t size = get_creds_array_size(creds1.get(), creds1_is_composite) +
|
149
|
+
get_creds_array_size(creds2.get(), creds2_is_composite);
|
150
|
+
inner_.reserve(size);
|
151
|
+
push_to_inner(std::move(creds1), creds1_is_composite);
|
152
|
+
push_to_inner(std::move(creds2), creds2_is_composite);
|
153
|
+
}
|
154
|
+
|
155
|
+
static grpc_core::RefCountedPtr<grpc_call_credentials>
|
156
|
+
composite_call_credentials_create(
|
157
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds1,
|
158
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds2) {
|
159
|
+
return grpc_core::MakeRefCounted<grpc_composite_call_credentials>(
|
160
|
+
std::move(creds1), std::move(creds2));
|
136
161
|
}
|
137
162
|
|
138
163
|
grpc_call_credentials* grpc_composite_call_credentials_create(
|
139
164
|
grpc_call_credentials* creds1, grpc_call_credentials* creds2,
|
140
165
|
void* reserved) {
|
141
|
-
size_t i;
|
142
|
-
size_t creds_array_byte_size;
|
143
|
-
grpc_call_credentials_array creds1_array;
|
144
|
-
grpc_call_credentials_array creds2_array;
|
145
|
-
grpc_composite_call_credentials* c;
|
146
166
|
GRPC_API_TRACE(
|
147
167
|
"grpc_composite_call_credentials_create(creds1=%p, creds2=%p, "
|
148
168
|
"reserved=%p)",
|
@@ -150,120 +170,40 @@ grpc_call_credentials* grpc_composite_call_credentials_create(
|
|
150
170
|
GPR_ASSERT(reserved == nullptr);
|
151
171
|
GPR_ASSERT(creds1 != nullptr);
|
152
172
|
GPR_ASSERT(creds2 != nullptr);
|
153
|
-
c = static_cast<grpc_composite_call_credentials*>(
|
154
|
-
gpr_zalloc(sizeof(grpc_composite_call_credentials)));
|
155
|
-
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE;
|
156
|
-
c->base.vtable = &composite_call_credentials_vtable;
|
157
|
-
gpr_ref_init(&c->base.refcount, 1);
|
158
|
-
creds1_array = get_creds_array(&creds1);
|
159
|
-
creds2_array = get_creds_array(&creds2);
|
160
|
-
c->inner.num_creds = creds1_array.num_creds + creds2_array.num_creds;
|
161
|
-
creds_array_byte_size = c->inner.num_creds * sizeof(grpc_call_credentials*);
|
162
|
-
c->inner.creds_array =
|
163
|
-
static_cast<grpc_call_credentials**>(gpr_zalloc(creds_array_byte_size));
|
164
|
-
for (i = 0; i < creds1_array.num_creds; i++) {
|
165
|
-
grpc_call_credentials* cur_creds = creds1_array.creds_array[i];
|
166
|
-
c->inner.creds_array[i] = grpc_call_credentials_ref(cur_creds);
|
167
|
-
}
|
168
|
-
for (i = 0; i < creds2_array.num_creds; i++) {
|
169
|
-
grpc_call_credentials* cur_creds = creds2_array.creds_array[i];
|
170
|
-
c->inner.creds_array[i + creds1_array.num_creds] =
|
171
|
-
grpc_call_credentials_ref(cur_creds);
|
172
|
-
}
|
173
|
-
return &c->base;
|
174
|
-
}
|
175
|
-
|
176
|
-
const grpc_call_credentials_array*
|
177
|
-
grpc_composite_call_credentials_get_credentials(grpc_call_credentials* creds) {
|
178
|
-
const grpc_composite_call_credentials* c =
|
179
|
-
reinterpret_cast<const grpc_composite_call_credentials*>(creds);
|
180
|
-
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0);
|
181
|
-
return &c->inner;
|
182
|
-
}
|
183
173
|
|
184
|
-
|
185
|
-
|
186
|
-
grpc_call_credentials** composite_creds) {
|
187
|
-
size_t i;
|
188
|
-
if (strcmp(creds->type, type) == 0) {
|
189
|
-
if (composite_creds != nullptr) *composite_creds = nullptr;
|
190
|
-
return creds;
|
191
|
-
} else if (strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE) == 0) {
|
192
|
-
const grpc_call_credentials_array* inner_creds_array =
|
193
|
-
grpc_composite_call_credentials_get_credentials(creds);
|
194
|
-
for (i = 0; i < inner_creds_array->num_creds; i++) {
|
195
|
-
if (strcmp(type, inner_creds_array->creds_array[i]->type) == 0) {
|
196
|
-
if (composite_creds != nullptr) *composite_creds = creds;
|
197
|
-
return inner_creds_array->creds_array[i];
|
198
|
-
}
|
199
|
-
}
|
200
|
-
}
|
201
|
-
return nullptr;
|
174
|
+
return composite_call_credentials_create(creds1->Ref(), creds2->Ref())
|
175
|
+
.release();
|
202
176
|
}
|
203
177
|
|
204
178
|
/* -- Composite channel credentials. -- */
|
205
179
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
grpc_channel_credentials_unref(c->inner_creds);
|
210
|
-
grpc_call_credentials_unref(c->call_creds);
|
211
|
-
}
|
212
|
-
|
213
|
-
static grpc_security_status composite_channel_create_security_connector(
|
214
|
-
grpc_channel_credentials* creds, grpc_call_credentials* call_creds,
|
180
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
181
|
+
grpc_composite_channel_credentials::create_security_connector(
|
182
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
215
183
|
const char* target, const grpc_channel_args* args,
|
216
|
-
|
217
|
-
|
218
|
-
reinterpret_cast<grpc_composite_channel_credentials*>(creds);
|
219
|
-
grpc_security_status status = GRPC_SECURITY_ERROR;
|
220
|
-
|
221
|
-
GPR_ASSERT(c->inner_creds != nullptr && c->call_creds != nullptr &&
|
222
|
-
c->inner_creds->vtable != nullptr &&
|
223
|
-
c->inner_creds->vtable->create_security_connector != nullptr);
|
184
|
+
grpc_channel_args** new_args) {
|
185
|
+
GPR_ASSERT(inner_creds_ != nullptr && call_creds_ != nullptr);
|
224
186
|
/* If we are passed a call_creds, create a call composite to pass it
|
225
187
|
downstream. */
|
226
188
|
if (call_creds != nullptr) {
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
status = c->inner_creds->vtable->create_security_connector(
|
231
|
-
c->inner_creds, composite_call_creds, target, args, sc, new_args);
|
232
|
-
grpc_call_credentials_unref(composite_call_creds);
|
189
|
+
return inner_creds_->create_security_connector(
|
190
|
+
composite_call_credentials_create(call_creds_, std::move(call_creds)),
|
191
|
+
target, args, new_args);
|
233
192
|
} else {
|
234
|
-
|
235
|
-
|
193
|
+
return inner_creds_->create_security_connector(call_creds_, target, args,
|
194
|
+
new_args);
|
236
195
|
}
|
237
|
-
return status;
|
238
196
|
}
|
239
197
|
|
240
|
-
static grpc_channel_credentials*
|
241
|
-
composite_channel_duplicate_without_call_credentials(
|
242
|
-
grpc_channel_credentials* creds) {
|
243
|
-
grpc_composite_channel_credentials* c =
|
244
|
-
reinterpret_cast<grpc_composite_channel_credentials*>(creds);
|
245
|
-
return grpc_channel_credentials_ref(c->inner_creds);
|
246
|
-
}
|
247
|
-
|
248
|
-
static grpc_channel_credentials_vtable composite_channel_credentials_vtable = {
|
249
|
-
composite_channel_destruct, composite_channel_create_security_connector,
|
250
|
-
composite_channel_duplicate_without_call_credentials};
|
251
|
-
|
252
198
|
grpc_channel_credentials* grpc_composite_channel_credentials_create(
|
253
199
|
grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds,
|
254
200
|
void* reserved) {
|
255
|
-
grpc_composite_channel_credentials* c =
|
256
|
-
static_cast<grpc_composite_channel_credentials*>(gpr_zalloc(sizeof(*c)));
|
257
201
|
GPR_ASSERT(channel_creds != nullptr && call_creds != nullptr &&
|
258
202
|
reserved == nullptr);
|
259
203
|
GRPC_API_TRACE(
|
260
204
|
"grpc_composite_channel_credentials_create(channel_creds=%p, "
|
261
205
|
"call_creds=%p, reserved=%p)",
|
262
206
|
3, (channel_creds, call_creds, reserved));
|
263
|
-
|
264
|
-
|
265
|
-
gpr_ref_init(&c->base.refcount, 1);
|
266
|
-
c->inner_creds = grpc_channel_credentials_ref(channel_creds);
|
267
|
-
c->call_creds = grpc_call_credentials_ref(call_creds);
|
268
|
-
return &c->base;
|
207
|
+
return grpc_core::New<grpc_composite_channel_credentials>(
|
208
|
+
channel_creds->Ref(), call_creds->Ref());
|
269
209
|
}
|