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
@@ -21,39 +21,75 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
+
#include "src/core/lib/gprpp/inlined_vector.h"
|
25
|
+
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
24
26
|
#include "src/core/lib/security/credentials/credentials.h"
|
25
27
|
|
26
|
-
|
27
|
-
grpc_call_credentials** creds_array;
|
28
|
-
size_t num_creds;
|
29
|
-
} grpc_call_credentials_array;
|
28
|
+
/* -- Composite channel credentials. -- */
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
class grpc_composite_channel_credentials : public grpc_channel_credentials {
|
31
|
+
public:
|
32
|
+
grpc_composite_channel_credentials(
|
33
|
+
grpc_core::RefCountedPtr<grpc_channel_credentials> channel_creds,
|
34
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds)
|
35
|
+
: grpc_channel_credentials(channel_creds->type()),
|
36
|
+
inner_creds_(std::move(channel_creds)),
|
37
|
+
call_creds_(std::move(call_creds)) {}
|
34
38
|
|
35
|
-
|
36
|
-
specified type (if found), if the creds is of type COMPOSITE.
|
37
|
-
If composite_creds is not NULL, *composite_creds will point to creds if of
|
38
|
-
type COMPOSITE in case of success. */
|
39
|
-
grpc_call_credentials* grpc_credentials_contains_type(
|
40
|
-
grpc_call_credentials* creds, const char* type,
|
41
|
-
grpc_call_credentials** composite_creds);
|
39
|
+
~grpc_composite_channel_credentials() override = default;
|
42
40
|
|
43
|
-
|
41
|
+
grpc_core::RefCountedPtr<grpc_channel_credentials>
|
42
|
+
duplicate_without_call_credentials() override {
|
43
|
+
return inner_creds_;
|
44
|
+
}
|
45
|
+
|
46
|
+
grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
47
|
+
create_security_connector(
|
48
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
49
|
+
const char* target, const grpc_channel_args* args,
|
50
|
+
grpc_channel_args** new_args) override;
|
44
51
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
grpc_call_credentials* call_creds;
|
49
|
-
|
52
|
+
const grpc_channel_credentials* inner_creds() const {
|
53
|
+
return inner_creds_.get();
|
54
|
+
}
|
55
|
+
const grpc_call_credentials* call_creds() const { return call_creds_.get(); }
|
56
|
+
grpc_call_credentials* mutable_call_creds() { return call_creds_.get(); }
|
57
|
+
|
58
|
+
private:
|
59
|
+
grpc_core::RefCountedPtr<grpc_channel_credentials> inner_creds_;
|
60
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds_;
|
61
|
+
};
|
50
62
|
|
51
63
|
/* -- Composite call credentials. -- */
|
52
64
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
65
|
+
class grpc_composite_call_credentials : public grpc_call_credentials {
|
66
|
+
public:
|
67
|
+
using CallCredentialsList =
|
68
|
+
grpc_core::InlinedVector<grpc_core::RefCountedPtr<grpc_call_credentials>,
|
69
|
+
2>;
|
70
|
+
|
71
|
+
grpc_composite_call_credentials(
|
72
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds1,
|
73
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds2);
|
74
|
+
~grpc_composite_call_credentials() override = default;
|
75
|
+
|
76
|
+
bool get_request_metadata(grpc_polling_entity* pollent,
|
77
|
+
grpc_auth_metadata_context context,
|
78
|
+
grpc_credentials_mdelem_array* md_array,
|
79
|
+
grpc_closure* on_request_metadata,
|
80
|
+
grpc_error** error) override;
|
81
|
+
|
82
|
+
void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array,
|
83
|
+
grpc_error* error) override;
|
84
|
+
|
85
|
+
const CallCredentialsList& inner() const { return inner_; }
|
86
|
+
|
87
|
+
private:
|
88
|
+
void push_to_inner(grpc_core::RefCountedPtr<grpc_call_credentials> creds,
|
89
|
+
bool is_composite);
|
90
|
+
|
91
|
+
CallCredentialsList inner_;
|
92
|
+
};
|
57
93
|
|
58
94
|
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H \
|
59
95
|
*/
|
@@ -39,120 +39,24 @@
|
|
39
39
|
|
40
40
|
/* -- Common. -- */
|
41
41
|
|
42
|
-
grpc_credentials_metadata_request* grpc_credentials_metadata_request_create(
|
43
|
-
grpc_call_credentials* creds) {
|
44
|
-
grpc_credentials_metadata_request* r =
|
45
|
-
static_cast<grpc_credentials_metadata_request*>(
|
46
|
-
gpr_zalloc(sizeof(grpc_credentials_metadata_request)));
|
47
|
-
r->creds = grpc_call_credentials_ref(creds);
|
48
|
-
return r;
|
49
|
-
}
|
50
|
-
|
51
|
-
void grpc_credentials_metadata_request_destroy(
|
52
|
-
grpc_credentials_metadata_request* r) {
|
53
|
-
grpc_call_credentials_unref(r->creds);
|
54
|
-
grpc_http_response_destroy(&r->response);
|
55
|
-
gpr_free(r);
|
56
|
-
}
|
57
|
-
|
58
|
-
grpc_channel_credentials* grpc_channel_credentials_ref(
|
59
|
-
grpc_channel_credentials* creds) {
|
60
|
-
if (creds == nullptr) return nullptr;
|
61
|
-
gpr_ref(&creds->refcount);
|
62
|
-
return creds;
|
63
|
-
}
|
64
|
-
|
65
|
-
void grpc_channel_credentials_unref(grpc_channel_credentials* creds) {
|
66
|
-
if (creds == nullptr) return;
|
67
|
-
if (gpr_unref(&creds->refcount)) {
|
68
|
-
if (creds->vtable->destruct != nullptr) {
|
69
|
-
creds->vtable->destruct(creds);
|
70
|
-
}
|
71
|
-
gpr_free(creds);
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
42
|
void grpc_channel_credentials_release(grpc_channel_credentials* creds) {
|
76
43
|
GRPC_API_TRACE("grpc_channel_credentials_release(creds=%p)", 1, (creds));
|
77
44
|
grpc_core::ExecCtx exec_ctx;
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
|
82
|
-
if (creds == nullptr) return nullptr;
|
83
|
-
gpr_ref(&creds->refcount);
|
84
|
-
return creds;
|
85
|
-
}
|
86
|
-
|
87
|
-
void grpc_call_credentials_unref(grpc_call_credentials* creds) {
|
88
|
-
if (creds == nullptr) return;
|
89
|
-
if (gpr_unref(&creds->refcount)) {
|
90
|
-
if (creds->vtable->destruct != nullptr) {
|
91
|
-
creds->vtable->destruct(creds);
|
92
|
-
}
|
93
|
-
gpr_free(creds);
|
94
|
-
}
|
45
|
+
if (creds) creds->Unref();
|
95
46
|
}
|
96
47
|
|
97
48
|
void grpc_call_credentials_release(grpc_call_credentials* creds) {
|
98
49
|
GRPC_API_TRACE("grpc_call_credentials_release(creds=%p)", 1, (creds));
|
99
50
|
grpc_core::ExecCtx exec_ctx;
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
bool grpc_call_credentials_get_request_metadata(
|
104
|
-
grpc_call_credentials* creds, grpc_polling_entity* pollent,
|
105
|
-
grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
|
106
|
-
grpc_closure* on_request_metadata, grpc_error** error) {
|
107
|
-
if (creds == nullptr || creds->vtable->get_request_metadata == nullptr) {
|
108
|
-
return true;
|
109
|
-
}
|
110
|
-
return creds->vtable->get_request_metadata(creds, pollent, context, md_array,
|
111
|
-
on_request_metadata, error);
|
112
|
-
}
|
113
|
-
|
114
|
-
void grpc_call_credentials_cancel_get_request_metadata(
|
115
|
-
grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
|
116
|
-
grpc_error* error) {
|
117
|
-
if (creds == nullptr ||
|
118
|
-
creds->vtable->cancel_get_request_metadata == nullptr) {
|
119
|
-
return;
|
120
|
-
}
|
121
|
-
creds->vtable->cancel_get_request_metadata(creds, md_array, error);
|
122
|
-
}
|
123
|
-
|
124
|
-
grpc_security_status grpc_channel_credentials_create_security_connector(
|
125
|
-
grpc_channel_credentials* channel_creds, const char* target,
|
126
|
-
const grpc_channel_args* args, grpc_channel_security_connector** sc,
|
127
|
-
grpc_channel_args** new_args) {
|
128
|
-
*new_args = nullptr;
|
129
|
-
if (channel_creds == nullptr) {
|
130
|
-
return GRPC_SECURITY_ERROR;
|
131
|
-
}
|
132
|
-
GPR_ASSERT(channel_creds->vtable->create_security_connector != nullptr);
|
133
|
-
return channel_creds->vtable->create_security_connector(
|
134
|
-
channel_creds, nullptr, target, args, sc, new_args);
|
135
|
-
}
|
136
|
-
|
137
|
-
grpc_channel_credentials*
|
138
|
-
grpc_channel_credentials_duplicate_without_call_credentials(
|
139
|
-
grpc_channel_credentials* channel_creds) {
|
140
|
-
if (channel_creds != nullptr && channel_creds->vtable != nullptr &&
|
141
|
-
channel_creds->vtable->duplicate_without_call_credentials != nullptr) {
|
142
|
-
return channel_creds->vtable->duplicate_without_call_credentials(
|
143
|
-
channel_creds);
|
144
|
-
} else {
|
145
|
-
return grpc_channel_credentials_ref(channel_creds);
|
146
|
-
}
|
51
|
+
if (creds) creds->Unref();
|
147
52
|
}
|
148
53
|
|
149
54
|
static void credentials_pointer_arg_destroy(void* p) {
|
150
|
-
|
55
|
+
static_cast<grpc_channel_credentials*>(p)->Unref();
|
151
56
|
}
|
152
57
|
|
153
58
|
static void* credentials_pointer_arg_copy(void* p) {
|
154
|
-
return
|
155
|
-
static_cast<grpc_channel_credentials*>(p));
|
59
|
+
return static_cast<grpc_channel_credentials*>(p)->Ref().release();
|
156
60
|
}
|
157
61
|
|
158
62
|
static int credentials_pointer_cmp(void* a, void* b) { return GPR_ICMP(a, b); }
|
@@ -191,63 +95,35 @@ grpc_channel_credentials* grpc_channel_credentials_find_in_args(
|
|
191
95
|
return nullptr;
|
192
96
|
}
|
193
97
|
|
194
|
-
grpc_server_credentials* grpc_server_credentials_ref(
|
195
|
-
grpc_server_credentials* creds) {
|
196
|
-
if (creds == nullptr) return nullptr;
|
197
|
-
gpr_ref(&creds->refcount);
|
198
|
-
return creds;
|
199
|
-
}
|
200
|
-
|
201
|
-
void grpc_server_credentials_unref(grpc_server_credentials* creds) {
|
202
|
-
if (creds == nullptr) return;
|
203
|
-
if (gpr_unref(&creds->refcount)) {
|
204
|
-
if (creds->vtable->destruct != nullptr) {
|
205
|
-
creds->vtable->destruct(creds);
|
206
|
-
}
|
207
|
-
if (creds->processor.destroy != nullptr &&
|
208
|
-
creds->processor.state != nullptr) {
|
209
|
-
creds->processor.destroy(creds->processor.state);
|
210
|
-
}
|
211
|
-
gpr_free(creds);
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
98
|
void grpc_server_credentials_release(grpc_server_credentials* creds) {
|
216
99
|
GRPC_API_TRACE("grpc_server_credentials_release(creds=%p)", 1, (creds));
|
217
100
|
grpc_core::ExecCtx exec_ctx;
|
218
|
-
|
101
|
+
if (creds) creds->Unref();
|
219
102
|
}
|
220
103
|
|
221
|
-
|
222
|
-
|
223
|
-
if (creds == nullptr || creds->vtable->create_security_connector == nullptr) {
|
224
|
-
gpr_log(GPR_ERROR, "Server credentials cannot create security context.");
|
225
|
-
return GRPC_SECURITY_ERROR;
|
226
|
-
}
|
227
|
-
return creds->vtable->create_security_connector(creds, sc);
|
228
|
-
}
|
229
|
-
|
230
|
-
void grpc_server_credentials_set_auth_metadata_processor(
|
231
|
-
grpc_server_credentials* creds, grpc_auth_metadata_processor processor) {
|
104
|
+
void grpc_server_credentials::set_auth_metadata_processor(
|
105
|
+
const grpc_auth_metadata_processor& processor) {
|
232
106
|
GRPC_API_TRACE(
|
233
107
|
"grpc_server_credentials_set_auth_metadata_processor("
|
234
108
|
"creds=%p, "
|
235
109
|
"processor=grpc_auth_metadata_processor { process: %p, state: %p })",
|
236
|
-
3, (
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
110
|
+
3, (this, (void*)(intptr_t)processor.process, processor.state));
|
111
|
+
DestroyProcessor();
|
112
|
+
processor_ = processor;
|
113
|
+
}
|
114
|
+
|
115
|
+
void grpc_server_credentials_set_auth_metadata_processor(
|
116
|
+
grpc_server_credentials* creds, grpc_auth_metadata_processor processor) {
|
117
|
+
GPR_DEBUG_ASSERT(creds != nullptr);
|
118
|
+
creds->set_auth_metadata_processor(processor);
|
243
119
|
}
|
244
120
|
|
245
121
|
static void server_credentials_pointer_arg_destroy(void* p) {
|
246
|
-
|
122
|
+
static_cast<grpc_server_credentials*>(p)->Unref();
|
247
123
|
}
|
248
124
|
|
249
125
|
static void* server_credentials_pointer_arg_copy(void* p) {
|
250
|
-
return
|
126
|
+
return static_cast<grpc_server_credentials*>(p)->Ref().release();
|
251
127
|
}
|
252
128
|
|
253
129
|
static int server_credentials_pointer_cmp(void* a, void* b) {
|
@@ -26,6 +26,7 @@
|
|
26
26
|
#include <grpc/support/sync.h>
|
27
27
|
#include "src/core/lib/transport/metadata_batch.h"
|
28
28
|
|
29
|
+
#include "src/core/lib/gprpp/ref_counted.h"
|
29
30
|
#include "src/core/lib/http/httpcli.h"
|
30
31
|
#include "src/core/lib/http/parser.h"
|
31
32
|
#include "src/core/lib/iomgr/polling_entity.h"
|
@@ -90,44 +91,46 @@ void grpc_override_well_known_credentials_path_getter(
|
|
90
91
|
|
91
92
|
#define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials"
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
// This type is forward declared as a C struct and we cannot define it as a
|
95
|
+
// class. Otherwise, compiler will complain about type mismatch due to
|
96
|
+
// -Wmismatched-tags.
|
97
|
+
struct grpc_channel_credentials
|
98
|
+
: grpc_core::RefCounted<grpc_channel_credentials> {
|
99
|
+
public:
|
100
|
+
explicit grpc_channel_credentials(const char* type) : type_(type) {}
|
101
|
+
virtual ~grpc_channel_credentials() = default;
|
102
|
+
|
103
|
+
// Creates a security connector for the channel. May also create new channel
|
104
|
+
// args for the channel to be used in place of the passed in const args if
|
105
|
+
// returned non NULL. In that case the caller is responsible for destroying
|
106
|
+
// new_args after channel creation.
|
107
|
+
virtual grpc_core::RefCountedPtr<grpc_channel_security_connector>
|
108
|
+
create_security_connector(
|
109
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
|
98
110
|
const char* target, const grpc_channel_args* args,
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
111
|
+
grpc_channel_args** new_args) {
|
112
|
+
// Tell clang-tidy that call_creds cannot be passed as const-ref.
|
113
|
+
call_creds.reset();
|
114
|
+
GRPC_ABSTRACT;
|
115
|
+
}
|
116
|
+
|
117
|
+
// Creates a version of the channel credentials without any attached call
|
118
|
+
// credentials. This can be used in order to open a channel to a non-trusted
|
119
|
+
// gRPC load balancer.
|
120
|
+
virtual grpc_core::RefCountedPtr<grpc_channel_credentials>
|
121
|
+
duplicate_without_call_credentials() {
|
122
|
+
// By default we just increment the refcount.
|
123
|
+
return Ref();
|
124
|
+
}
|
125
|
+
|
126
|
+
const char* type() const { return type_; }
|
127
|
+
|
128
|
+
GRPC_ABSTRACT_BASE_CLASS
|
129
|
+
|
130
|
+
private:
|
131
|
+
const char* type_;
|
109
132
|
};
|
110
133
|
|
111
|
-
grpc_channel_credentials* grpc_channel_credentials_ref(
|
112
|
-
grpc_channel_credentials* creds);
|
113
|
-
void grpc_channel_credentials_unref(grpc_channel_credentials* creds);
|
114
|
-
|
115
|
-
/* Creates a security connector for the channel. May also create new channel
|
116
|
-
args for the channel to be used in place of the passed in const args if
|
117
|
-
returned non NULL. In that case the caller is responsible for destroying
|
118
|
-
new_args after channel creation. */
|
119
|
-
grpc_security_status grpc_channel_credentials_create_security_connector(
|
120
|
-
grpc_channel_credentials* creds, const char* target,
|
121
|
-
const grpc_channel_args* args, grpc_channel_security_connector** sc,
|
122
|
-
grpc_channel_args** new_args);
|
123
|
-
|
124
|
-
/* Creates a version of the channel credentials without any attached call
|
125
|
-
credentials. This can be used in order to open a channel to a non-trusted
|
126
|
-
gRPC load balancer. */
|
127
|
-
grpc_channel_credentials*
|
128
|
-
grpc_channel_credentials_duplicate_without_call_credentials(
|
129
|
-
grpc_channel_credentials* creds);
|
130
|
-
|
131
134
|
/* Util to encapsulate the channel credentials in a channel arg. */
|
132
135
|
grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials* credentials);
|
133
136
|
|
@@ -158,44 +161,39 @@ void grpc_credentials_mdelem_array_destroy(grpc_credentials_mdelem_array* list);
|
|
158
161
|
|
159
162
|
/* --- grpc_call_credentials. --- */
|
160
163
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
164
|
+
// This type is forward declared as a C struct and we cannot define it as a
|
165
|
+
// class. Otherwise, compiler will complain about type mismatch due to
|
166
|
+
// -Wmismatched-tags.
|
167
|
+
struct grpc_call_credentials
|
168
|
+
: public grpc_core::RefCounted<grpc_call_credentials> {
|
169
|
+
public:
|
170
|
+
explicit grpc_call_credentials(const char* type) : type_(type) {}
|
171
|
+
virtual ~grpc_call_credentials() = default;
|
172
|
+
|
173
|
+
// Returns true if completed synchronously, in which case \a error will
|
174
|
+
// be set to indicate the result. Otherwise, \a on_request_metadata will
|
175
|
+
// be invoked asynchronously when complete. \a md_array will be populated
|
176
|
+
// with the resulting metadata once complete.
|
177
|
+
virtual bool get_request_metadata(grpc_polling_entity* pollent,
|
178
|
+
grpc_auth_metadata_context context,
|
179
|
+
grpc_credentials_mdelem_array* md_array,
|
180
|
+
grpc_closure* on_request_metadata,
|
181
|
+
grpc_error** error) GRPC_ABSTRACT;
|
182
|
+
|
183
|
+
// Cancels a pending asynchronous operation started by
|
184
|
+
// grpc_call_credentials_get_request_metadata() with the corresponding
|
185
|
+
// value of \a md_array.
|
186
|
+
virtual void cancel_get_request_metadata(
|
187
|
+
grpc_credentials_mdelem_array* md_array, grpc_error* error) GRPC_ABSTRACT;
|
188
|
+
|
189
|
+
const char* type() const { return type_; }
|
190
|
+
|
191
|
+
GRPC_ABSTRACT_BASE_CLASS
|
192
|
+
|
193
|
+
private:
|
194
|
+
const char* type_;
|
178
195
|
};
|
179
196
|
|
180
|
-
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds);
|
181
|
-
void grpc_call_credentials_unref(grpc_call_credentials* creds);
|
182
|
-
|
183
|
-
/// Returns true if completed synchronously, in which case \a error will
|
184
|
-
/// be set to indicate the result. Otherwise, \a on_request_metadata will
|
185
|
-
/// be invoked asynchronously when complete. \a md_array will be populated
|
186
|
-
/// with the resulting metadata once complete.
|
187
|
-
bool grpc_call_credentials_get_request_metadata(
|
188
|
-
grpc_call_credentials* creds, grpc_polling_entity* pollent,
|
189
|
-
grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
|
190
|
-
grpc_closure* on_request_metadata, grpc_error** error);
|
191
|
-
|
192
|
-
/// Cancels a pending asynchronous operation started by
|
193
|
-
/// grpc_call_credentials_get_request_metadata() with the corresponding
|
194
|
-
/// value of \a md_array.
|
195
|
-
void grpc_call_credentials_cancel_get_request_metadata(
|
196
|
-
grpc_call_credentials* c, grpc_credentials_mdelem_array* md_array,
|
197
|
-
grpc_error* error);
|
198
|
-
|
199
197
|
/* Metadata-only credentials with the specified key and value where
|
200
198
|
asynchronicity can be simulated for testing. */
|
201
199
|
grpc_call_credentials* grpc_md_only_test_credentials_create(
|
@@ -203,26 +201,40 @@ grpc_call_credentials* grpc_md_only_test_credentials_create(
|
|
203
201
|
|
204
202
|
/* --- grpc_server_credentials. --- */
|
205
203
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
const grpc_server_credentials_vtable* vtable;
|
214
|
-
const char* type;
|
215
|
-
gpr_refcount refcount;
|
216
|
-
grpc_auth_metadata_processor processor;
|
217
|
-
};
|
204
|
+
// This type is forward declared as a C struct and we cannot define it as a
|
205
|
+
// class. Otherwise, compiler will complain about type mismatch due to
|
206
|
+
// -Wmismatched-tags.
|
207
|
+
struct grpc_server_credentials
|
208
|
+
: public grpc_core::RefCounted<grpc_server_credentials> {
|
209
|
+
public:
|
210
|
+
explicit grpc_server_credentials(const char* type) : type_(type) {}
|
218
211
|
|
219
|
-
|
220
|
-
grpc_server_credentials* creds, grpc_server_security_connector** sc);
|
212
|
+
virtual ~grpc_server_credentials() { DestroyProcessor(); }
|
221
213
|
|
222
|
-
|
223
|
-
|
214
|
+
virtual grpc_core::RefCountedPtr<grpc_server_security_connector>
|
215
|
+
create_security_connector() GRPC_ABSTRACT;
|
224
216
|
|
225
|
-
|
217
|
+
const char* type() const { return type_; }
|
218
|
+
|
219
|
+
const grpc_auth_metadata_processor& auth_metadata_processor() const {
|
220
|
+
return processor_;
|
221
|
+
}
|
222
|
+
void set_auth_metadata_processor(
|
223
|
+
const grpc_auth_metadata_processor& processor);
|
224
|
+
|
225
|
+
GRPC_ABSTRACT_BASE_CLASS
|
226
|
+
|
227
|
+
private:
|
228
|
+
void DestroyProcessor() {
|
229
|
+
if (processor_.destroy != nullptr && processor_.state != nullptr) {
|
230
|
+
processor_.destroy(processor_.state);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
const char* type_;
|
235
|
+
grpc_auth_metadata_processor processor_ =
|
236
|
+
grpc_auth_metadata_processor(); // Zero-initialize the C struct.
|
237
|
+
};
|
226
238
|
|
227
239
|
#define GRPC_SERVER_CREDENTIALS_ARG "grpc.server_credentials"
|
228
240
|
|
@@ -233,15 +245,27 @@ grpc_server_credentials* grpc_find_server_credentials_in_args(
|
|
233
245
|
|
234
246
|
/* -- Credentials Metadata Request. -- */
|
235
247
|
|
236
|
-
|
237
|
-
|
248
|
+
struct grpc_credentials_metadata_request {
|
249
|
+
explicit grpc_credentials_metadata_request(
|
250
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds)
|
251
|
+
: creds(std::move(creds)) {}
|
252
|
+
~grpc_credentials_metadata_request() {
|
253
|
+
grpc_http_response_destroy(&response);
|
254
|
+
}
|
255
|
+
|
256
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds;
|
238
257
|
grpc_http_response response;
|
239
|
-
}
|
258
|
+
};
|
240
259
|
|
241
|
-
grpc_credentials_metadata_request*
|
242
|
-
|
260
|
+
inline grpc_credentials_metadata_request*
|
261
|
+
grpc_credentials_metadata_request_create(
|
262
|
+
grpc_core::RefCountedPtr<grpc_call_credentials> creds) {
|
263
|
+
return grpc_core::New<grpc_credentials_metadata_request>(std::move(creds));
|
264
|
+
}
|
243
265
|
|
244
|
-
void grpc_credentials_metadata_request_destroy(
|
245
|
-
grpc_credentials_metadata_request* r)
|
266
|
+
inline void grpc_credentials_metadata_request_destroy(
|
267
|
+
grpc_credentials_metadata_request* r) {
|
268
|
+
grpc_core::Delete(r);
|
269
|
+
}
|
246
270
|
|
247
271
|
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */
|