secure_credentials.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
20 
21 #include <string.h>
22 
23 #include <algorithm>
24 #include <map>
25 #include <utility>
26 
27 #include "absl/strings/str_join.h"
28 
31 #include <grpc/slice.h>
32 #include <grpc/support/alloc.h>
33 #include <grpc/support/log.h>
35 #include <grpc/support/time.h>
36 #include <grpcpp/channel.h>
40 #include <grpcpp/support/slice.h>
41 #include <grpcpp/support/status.h>
42 
43 #include "src/core/lib/gpr/env.h"
48 #include "src/core/lib/json/json.h"
53 
54 namespace grpc {
55 
58  grpc_channel_credentials* c_creds)
59  : c_creds_(c_creds) {
61 }
62 
64  const std::string& target, const ChannelArguments& args) {
66  target, args,
67  std::vector<std::unique_ptr<
69 }
70 
71 std::shared_ptr<Channel>
73  const std::string& target, const ChannelArguments& args,
74  std::vector<
75  std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
76  interceptor_creators) {
77  grpc_channel_args channel_args;
78  args.SetChannelArgs(&channel_args);
80  args.GetSslTargetNameOverride(),
81  grpc_channel_create(target.c_str(), c_creds_, &channel_args),
82  std::move(interceptor_creators));
83 }
84 
86  : c_creds_(c_creds) {
88 }
89 
92 }
93 
94 namespace internal {
95 
96 std::shared_ptr<ChannelCredentials> WrapChannelCredentials(
97  grpc_channel_credentials* creds) {
98  return creds == nullptr ? nullptr
99  : std::shared_ptr<ChannelCredentials>(
100  new SecureChannelCredentials(creds));
101 }
102 
103 } // namespace internal
104 
105 namespace {
106 
107 std::shared_ptr<CallCredentials> WrapCallCredentials(
108  grpc_call_credentials* creds) {
109  return creds == nullptr ? nullptr
110  : std::shared_ptr<CallCredentials>(
111  new SecureCallCredentials(creds));
112 }
113 } // namespace
114 
115 std::shared_ptr<ChannelCredentials> GoogleDefaultCredentials() {
116  grpc::GrpcLibraryCodegen init; // To call grpc_init().
119 }
120 
121 std::shared_ptr<CallCredentials> ExternalAccountCredentials(
122  const grpc::string& json_string, const std::vector<grpc::string>& scopes) {
123  grpc::GrpcLibraryCodegen init; // To call grpc_init().
124  return WrapCallCredentials(grpc_external_account_credentials_create(
125  json_string.c_str(), absl::StrJoin(scopes, ",").c_str()));
126 }
127 
128 // Builds SSL Credentials given SSL specific options
129 std::shared_ptr<ChannelCredentials> SslCredentials(
131  grpc::GrpcLibraryCodegen init; // To call grpc_init().
132  grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {
133  options.pem_private_key.c_str(), options.pem_cert_chain.c_str()};
134 
136  options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(),
137  options.pem_private_key.empty() ? nullptr : &pem_key_cert_pair, nullptr,
138  nullptr);
139  return internal::WrapChannelCredentials(c_creds);
140 }
141 
142 namespace experimental {
143 
144 namespace {
145 
146 void ClearStsCredentialsOptions(StsCredentialsOptions* options) {
147  if (options == nullptr) return;
148  options->token_exchange_service_uri.clear();
149  options->resource.clear();
150  options->audience.clear();
151  options->scope.clear();
152  options->requested_token_type.clear();
153  options->subject_token_path.clear();
154  options->subject_token_type.clear();
155  options->actor_token_path.clear();
156  options->actor_token_type.clear();
157 }
158 
159 } // namespace
160 
161 // Builds STS credentials options from JSON.
164  if (options == nullptr) {
166  "options cannot be nullptr.");
167  }
168  ClearStsCredentialsOptions(options);
170  grpc_core::Json json = grpc_core::Json::Parse(json_string.c_str(), &error);
171  if (!GRPC_ERROR_IS_NONE(error) ||
174  return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid json.");
175  }
176 
177  // Required fields.
178  const char* value = grpc_json_get_string_property(
179  json, "token_exchange_service_uri", nullptr);
180  if (value == nullptr) {
181  ClearStsCredentialsOptions(options);
183  "token_exchange_service_uri must be specified.");
184  }
185  options->token_exchange_service_uri.assign(value);
186  value = grpc_json_get_string_property(json, "subject_token_path", nullptr);
187  if (value == nullptr) {
188  ClearStsCredentialsOptions(options);
190  "subject_token_path must be specified.");
191  }
192  options->subject_token_path.assign(value);
193  value = grpc_json_get_string_property(json, "subject_token_type", nullptr);
194  if (value == nullptr) {
195  ClearStsCredentialsOptions(options);
197  "subject_token_type must be specified.");
198  }
199  options->subject_token_type.assign(value);
200 
201  // Optional fields.
202  value = grpc_json_get_string_property(json, "resource", nullptr);
203  if (value != nullptr) options->resource.assign(value);
204  value = grpc_json_get_string_property(json, "audience", nullptr);
205  if (value != nullptr) options->audience.assign(value);
206  value = grpc_json_get_string_property(json, "scope", nullptr);
207  if (value != nullptr) options->scope.assign(value);
208  value = grpc_json_get_string_property(json, "requested_token_type", nullptr);
209  if (value != nullptr) options->requested_token_type.assign(value);
210  value = grpc_json_get_string_property(json, "actor_token_path", nullptr);
211  if (value != nullptr) options->actor_token_path.assign(value);
212  value = grpc_json_get_string_property(json, "actor_token_type", nullptr);
213  if (value != nullptr) options->actor_token_type.assign(value);
214 
215  return grpc::Status();
216 }
217 
218 // Builds STS credentials Options from the $STS_CREDENTIALS env var.
220  if (options == nullptr) {
222  "options cannot be nullptr.");
223  }
224  ClearStsCredentialsOptions(options);
225  grpc_slice json_string = grpc_empty_slice();
226  char* sts_creds_path = gpr_getenv("STS_CREDENTIALS");
229  // NOLINTNEXTLINE(clang-diagnostic-unused-lambda-capture)
230  auto cleanup = [&json_string, &sts_creds_path, &error, &status]() {
231  grpc_slice_unref_internal(json_string);
232  gpr_free(sts_creds_path);
234  return status;
235  };
236 
237  if (sts_creds_path == nullptr) {
239  "STS_CREDENTIALS environment variable not set.");
240  return cleanup();
241  }
242  error = grpc_load_file(sts_creds_path, 1, &json_string);
243  if (!GRPC_ERROR_IS_NONE(error)) {
244  status =
246  return cleanup();
247  }
249  reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(json_string)),
250  options);
251  return cleanup();
252 }
253 
254 // C++ to Core STS Credentials options.
258  memset(&opts, 0, sizeof(opts));
259  opts.token_exchange_service_uri = options.token_exchange_service_uri.c_str();
260  opts.resource = options.resource.c_str();
261  opts.audience = options.audience.c_str();
262  opts.scope = options.scope.c_str();
263  opts.requested_token_type = options.requested_token_type.c_str();
264  opts.subject_token_path = options.subject_token_path.c_str();
265  opts.subject_token_type = options.subject_token_type.c_str();
266  opts.actor_token_path = options.actor_token_path.c_str();
267  opts.actor_token_type = options.actor_token_type.c_str();
268  return opts;
269 }
270 
271 // Builds STS credentials.
272 std::shared_ptr<CallCredentials> StsCredentials(
275  return WrapCallCredentials(grpc_sts_credentials_create(&opts, nullptr));
276 }
277 
278 std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
279  std::unique_ptr<MetadataCredentialsPlugin> plugin,
280  grpc_security_level min_security_level) {
281  grpc::GrpcLibraryCodegen init; // To call grpc_init().
282  const char* type = plugin->GetType();
289  return WrapCallCredentials(grpc_metadata_credentials_create_from_plugin(
290  c_plugin, min_security_level, nullptr));
291 }
292 
293 // Builds ALTS Credentials given ALTS specific options
294 std::shared_ptr<ChannelCredentials> AltsCredentials(
296  grpc::GrpcLibraryCodegen init; // To call grpc_init().
297  grpc_alts_credentials_options* c_options =
299  for (const auto& service_account : options.target_service_accounts) {
301  c_options, service_account.c_str());
302  }
305  return internal::WrapChannelCredentials(c_creds);
306 }
307 
308 // Builds Local Credentials
309 std::shared_ptr<ChannelCredentials> LocalCredentials(
311  grpc::GrpcLibraryCodegen init; // To call grpc_init().
313 }
314 
315 // Builds TLS Credentials given TLS options.
316 std::shared_ptr<ChannelCredentials> TlsCredentials(
319  grpc_tls_credentials_create(options.c_credentials_options()));
320 }
321 
322 } // namespace experimental
323 
324 // Builds credentials for use when running in GCE
325 std::shared_ptr<CallCredentials> GoogleComputeEngineCredentials() {
326  grpc::GrpcLibraryCodegen init; // To call grpc_init().
327  return WrapCallCredentials(
329 }
330 
331 // Builds JWT credentials.
332 std::shared_ptr<CallCredentials> ServiceAccountJWTAccessCredentials(
333  const std::string& json_key, long token_lifetime_seconds) {
334  grpc::GrpcLibraryCodegen init; // To call grpc_init().
335  if (token_lifetime_seconds <= 0) {
337  "Trying to create JWTCredentials with non-positive lifetime");
338  return WrapCallCredentials(nullptr);
339  }
340  gpr_timespec lifetime =
341  gpr_time_from_seconds(token_lifetime_seconds, GPR_TIMESPAN);
342  return WrapCallCredentials(grpc_service_account_jwt_access_credentials_create(
343  json_key.c_str(), lifetime, nullptr));
344 }
345 
346 // Builds refresh token credentials.
347 std::shared_ptr<CallCredentials> GoogleRefreshTokenCredentials(
348  const std::string& json_refresh_token) {
349  grpc::GrpcLibraryCodegen init; // To call grpc_init().
350  return WrapCallCredentials(grpc_google_refresh_token_credentials_create(
351  json_refresh_token.c_str(), nullptr));
352 }
353 
354 // Builds access token credentials.
355 std::shared_ptr<CallCredentials> AccessTokenCredentials(
356  const std::string& access_token) {
357  grpc::GrpcLibraryCodegen init; // To call grpc_init().
358  return WrapCallCredentials(
359  grpc_access_token_credentials_create(access_token.c_str(), nullptr));
360 }
361 
362 // Builds IAM credentials.
363 std::shared_ptr<CallCredentials> GoogleIAMCredentials(
364  const std::string& authorization_token,
365  const std::string& authority_selector) {
366  grpc::GrpcLibraryCodegen init; // To call grpc_init().
367  return WrapCallCredentials(grpc_google_iam_credentials_create(
368  authorization_token.c_str(), authority_selector.c_str(), nullptr));
369 }
370 
371 // Combines one channel credentials and one call credentials into a channel
372 // composite credentials.
373 std::shared_ptr<ChannelCredentials> CompositeChannelCredentials(
374  const std::shared_ptr<ChannelCredentials>& channel_creds,
375  const std::shared_ptr<CallCredentials>& call_creds) {
376  // Note that we are not saving shared_ptrs to the two credentials passed in
377  // here. This is OK because the underlying C objects (i.e., channel_creds and
378  // call_creds) into grpc_composite_credentials_create will see their refcounts
379  // incremented.
380  SecureChannelCredentials* s_channel_creds =
381  channel_creds->AsSecureCredentials();
382  SecureCallCredentials* s_call_creds = call_creds->AsSecureCredentials();
383  if (s_channel_creds && s_call_creds) {
386  s_channel_creds->GetRawCreds(), s_call_creds->GetRawCreds(),
387  nullptr));
388  }
389  return nullptr;
390 }
391 
392 std::shared_ptr<CallCredentials> CompositeCallCredentials(
393  const std::shared_ptr<CallCredentials>& creds1,
394  const std::shared_ptr<CallCredentials>& creds2) {
395  SecureCallCredentials* s_creds1 = creds1->AsSecureCredentials();
396  SecureCallCredentials* s_creds2 = creds2->AsSecureCredentials();
397  if (s_creds1 != nullptr && s_creds2 != nullptr) {
398  return WrapCallCredentials(grpc_composite_call_credentials_create(
399  s_creds1->GetRawCreds(), s_creds2->GetRawCreds(), nullptr));
400  }
401  return nullptr;
402 }
403 
404 std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
405  std::unique_ptr<MetadataCredentialsPlugin> plugin) {
406  grpc::GrpcLibraryCodegen init; // To call grpc_init().
407  const char* type = plugin->GetType();
414  return WrapCallCredentials(grpc_metadata_credentials_create_from_plugin(
415  c_plugin, GRPC_PRIVACY_AND_INTEGRITY, nullptr));
416 }
417 
418 namespace {
419 void DeleteWrapper(void* wrapper, grpc_error_handle /*ignored*/) {
420  MetadataCredentialsPluginWrapper* w =
421  static_cast<MetadataCredentialsPluginWrapper*>(wrapper);
422  delete w;
423 }
424 } // namespace
425 
430  return gpr_strdup(w->plugin_->DebugString().c_str());
431 }
432 
434  if (wrapper == nullptr) return;
435  grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
437  grpc_core::Executor::Run(GRPC_CLOSURE_CREATE(DeleteWrapper, wrapper, nullptr),
439 }
440 
443  grpc_credentials_plugin_metadata_cb cb, void* user_data,
445  size_t* num_creds_md, grpc_status_code* status,
446  const char** error_details) {
450  if (!w->plugin_) {
451  *num_creds_md = 0;
453  *error_details = nullptr;
454  return 1;
455  }
456  if (w->plugin_->IsBlocking()) {
457  // The internals of context may be destroyed if GetMetadata is cancelled.
458  // Make a copy for InvokePlugin.
460  grpc_auth_metadata_context_copy(&context, &context_copy);
461  // Asynchronous return.
462  w->thread_pool_->Add([w, context_copy, cb, user_data]() mutable {
463  w->MetadataCredentialsPluginWrapper::InvokePlugin(
464  context_copy, cb, user_data, nullptr, nullptr, nullptr, nullptr);
465  grpc_auth_metadata_context_reset(&context_copy);
466  });
467  return 0;
468  } else {
469  // Synchronous return.
470  w->InvokePlugin(context, cb, user_data, creds_md, num_creds_md, status,
471  error_details);
472  return 1;
473  }
474 }
475 
476 namespace {
477 
478 void UnrefMetadata(const std::vector<grpc_metadata>& md) {
479  for (const auto& metadatum : md) {
480  grpc_slice_unref(metadatum.key);
481  grpc_slice_unref(metadatum.value);
482  }
483 }
484 
485 } // namespace
486 
489  void* user_data, grpc_metadata creds_md[4], size_t* num_creds_md,
490  grpc_status_code* status_code, const char** error_details) {
491  std::multimap<std::string, std::string> metadata;
492 
493  // const_cast is safe since the SecureAuthContext only inc/dec the refcount
494  // and the object is passed as a const ref to plugin_->GetMetadata.
495  SecureAuthContext cpp_channel_auth_context(
496  const_cast<grpc_auth_context*>(context.channel_auth_context));
497 
498  Status status = plugin_->GetMetadata(context.service_url, context.method_name,
499  cpp_channel_auth_context, &metadata);
500  std::vector<grpc_metadata> md;
501  for (auto& metadatum : metadata) {
502  grpc_metadata md_entry;
503  md_entry.key = SliceFromCopiedString(metadatum.first);
504  md_entry.value = SliceFromCopiedString(metadatum.second);
505  md.push_back(md_entry);
506  }
507  if (creds_md != nullptr) {
508  // Synchronous return.
510  *num_creds_md = 0;
511  *status_code = GRPC_STATUS_INTERNAL;
512  *error_details = gpr_strdup(
513  "blocking plugin credentials returned too many metadata keys");
514  UnrefMetadata(md);
515  } else {
516  for (const auto& elem : md) {
517  creds_md[*num_creds_md].key = elem.key;
518  creds_md[*num_creds_md].value = elem.value;
519  ++(*num_creds_md);
520  }
521  *status_code = static_cast<grpc_status_code>(status.error_code());
522  *error_details =
523  status.ok() ? nullptr : gpr_strdup(status.error_message().c_str());
524  }
525  } else {
526  // Asynchronous return.
527  cb(user_data, md.empty() ? nullptr : &md[0], md.size(),
528  static_cast<grpc_status_code>(status.error_code()),
529  status.error_message().c_str());
530  UnrefMetadata(md);
531  }
532 }
533 
535  std::unique_ptr<MetadataCredentialsPlugin> plugin)
536  : plugin_(std::move(plugin)) {
537  if (plugin_->IsBlocking()) {
539  }
540 }
541 
542 } // namespace grpc
GPR_TIMESPAN
@ GPR_TIMESPAN
Definition: gpr_types.h:45
grpc_slice_unref
GPRAPI void grpc_slice_unref(grpc_slice s)
Definition: slice_api.cc:32
grpc::CreateChannelInternal
std::shared_ptr< Channel > CreateChannelInternal(const std::string &host, grpc_channel *c_channel, std::vector< std::unique_ptr< experimental::ClientInterceptorFactoryInterface >> interceptor_creators)
grpc_alts_credentials_options_destroy
GRPCAPI void grpc_alts_credentials_options_destroy(grpc_alts_credentials_options *options)
Definition: grpc_alts_credentials_options.cc:38
grpc::experimental::StsCredentialsOptionsFromJson
grpc::Status StsCredentialsOptionsFromJson(const std::string &json_string, StsCredentialsOptions *options)
Definition: secure_credentials.cc:162
tls_credentials_options.h
grpc::status
auto status
Definition: cpp/client/credentials_test.cc:200
GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX
#define GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX
Definition: grpc_security.h:417
grpc_auth_context
Definition: security_context.h:63
grpc_credentials_plugin_metadata_cb
void(* grpc_credentials_plugin_metadata_cb)(void *user_data, const grpc_metadata *creds_md, size_t num_creds_md, grpc_status_code status, const char *error_details)
Definition: grpc_security.h:385
init
const char * init
Definition: upb/upb/bindings/lua/main.c:49
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
grpc::SecureChannelCredentials::GetRawCreds
grpc_channel_credentials * GetRawCreds()
Definition: secure_credentials.h:56
create_channel_internal.h
log.h
grpc::SecureCallCredentials::SecureCallCredentials
SecureCallCredentials(grpc_call_credentials *c_creds)
Definition: secure_credentials.cc:85
grpc_load_file
grpc_error_handle grpc_load_file(const char *filename, int add_null_terminator, grpc_slice *output)
Definition: load_file.cc:33
grpc_core::Json::type
Type type() const
Definition: src/core/lib/json/json.h:174
cleanup
void cleanup(void)
Definition: bloaty/third_party/zlib/examples/enough.c:182
grpc::experimental::MetadataCredentialsFromPlugin
std::shared_ptr< CallCredentials > MetadataCredentialsFromPlugin(std::unique_ptr< MetadataCredentialsPlugin > plugin, grpc_security_level min_security_level)
Definition: secure_credentials.cc:278
metadata
Definition: cq_verifier.cc:48
grpc::gpr_free
gpr_free(creds_file_name)
memset
return memset(p, 0, total)
load_file.h
grpc
Definition: grpcpp/alarm.h:33
grpc_core::Json::Type::OBJECT
@ OBJECT
slice.h
grpc::internal::GrpcLibraryInitializer::summon
int summon()
Definition: grpcpp/impl/grpc_library.h:54
grpc::SslCredentials
std::shared_ptr< ChannelCredentials > SslCredentials(const SslCredentialsOptions &options)
Builds SSL Credentials given SSL specific options.
Definition: secure_credentials.cc:129
grpc_sts_credentials_options
Definition: grpc_security.h:355
grpc::SecureChannelCredentials::CreateChannelWithInterceptors
std::shared_ptr< Channel > CreateChannelWithInterceptors(const std::string &target, const ChannelArguments &args, std::vector< std::unique_ptr< grpc::experimental::ClientInterceptorFactoryInterface >> interceptor_creators) override
Definition: secure_credentials.cc:72
grpc::g_gli_initializer
static grpc::internal::GrpcLibraryInitializer g_gli_initializer
Definition: channel_cc.cc:52
string.h
grpc::MetadataCredentialsPluginWrapper::InvokePlugin
void InvokePlugin(grpc_auth_metadata_context context, grpc_credentials_plugin_metadata_cb cb, void *user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t *num_creds_md, grpc_status_code *status_code, const char **error_details)
Definition: secure_credentials.cc:487
options
double_dict options[]
Definition: capstone_test.c:55
grpc_google_iam_credentials_create
GRPCAPI grpc_call_credentials * grpc_google_iam_credentials_create(const char *authorization_token, const char *authority_selector, void *reserved)
Definition: iam_credentials.cc:70
grpc::MetadataCredentialsPluginWrapper
Definition: secure_credentials.h:109
grpc::experimental::StsCredentialsOptionsFromEnv
grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions *options)
Definition: secure_credentials.cc:219
grpc::SliceFromCopiedString
grpc_slice SliceFromCopiedString(const std::string &str)
Definition: include/grpcpp/impl/codegen/slice.h:149
grpc::experimental::ClientInterceptorFactoryInterface
Definition: impl/codegen/client_interceptor.h:48
metadata
struct metadata metadata
elem
Timer elem
Definition: event_engine/iomgr_event_engine/timer_heap_test.cc:109
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
error
grpc_error_handle error
Definition: retry_filter.cc:499
grpc::MetadataCredentialsPluginWrapper::MetadataCredentialsPluginWrapper
MetadataCredentialsPluginWrapper(std::unique_ptr< MetadataCredentialsPlugin > plugin)
Definition: secure_credentials.cc:534
grpc_status_code
grpc_status_code
Definition: include/grpc/impl/codegen/status.h:28
secure_credentials.h
slice.h
grpc::CompositeChannelCredentials
std::shared_ptr< ChannelCredentials > CompositeChannelCredentials(const std::shared_ptr< ChannelCredentials > &channel_creds, const std::shared_ptr< CallCredentials > &call_creds)
Definition: secure_credentials.cc:373
grpc_metadata_credentials_create_from_plugin
GRPCAPI grpc_call_credentials * grpc_metadata_credentials_create_from_plugin(grpc_metadata_credentials_plugin plugin, grpc_security_level min_security_level, void *reserved)
Definition: plugin_credentials.cc:208
cstest_report.opts
opts
Definition: cstest_report.py:81
closure.h
grpc_call_credentials
Definition: src/core/lib/security/credentials/credentials.h:189
GRPC_CALL_OK
@ GRPC_CALL_OK
Definition: grpc_types.h:466
grpc::SecureCallCredentials::AsSecureCredentials
SecureCallCredentials * AsSecureCredentials() override
Definition: secure_credentials.h:82
grpc_google_compute_engine_credentials_create
GRPCAPI grpc_call_credentials * grpc_google_compute_engine_credentials_create(void *reserved)
Definition: oauth2_credentials.cc:421
grpc_core::ApplicationCallbackExecCtx
Definition: exec_ctx.h:283
secure_auth_context.h
grpc_json_get_string_property
const char * grpc_json_get_string_property(const grpc_core::Json &json, const char *prop_name, grpc_error_handle *error)
Definition: src/core/lib/security/util/json_util.cc:33
env.h
grpc_tls_credentials_create
grpc_channel_credentials * grpc_tls_credentials_create(grpc_tls_credentials_options *options)
Definition: tls_credentials.cc:146
time.h
grpc::GoogleDefaultCredentials
std::shared_ptr< ChannelCredentials > GoogleDefaultCredentials()
Definition: secure_credentials.cc:115
grpc_composite_call_credentials_create
GRPCAPI grpc_call_credentials * grpc_composite_call_credentials_create(grpc_call_credentials *creds1, grpc_call_credentials *creds2, void *reserved)
Definition: composite_credentials.cc:129
GRPC_CLOSURE_CREATE
#define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler)
Definition: closure.h:160
grpc::SecureCallCredentials
Definition: secure_credentials.h:72
grpc_auth_metadata_context_reset
GRPCAPI void grpc_auth_metadata_context_reset(grpc_auth_metadata_context *context)
Definition: client_auth_filter.cc:71
grpc::GrpcLibraryCodegen
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpcpp/impl/codegen/grpc_library.h:40
grpc::ExternalAccountCredentials
std::shared_ptr< CallCredentials > ExternalAccountCredentials(const grpc::string &json_string, const std::vector< grpc::string > &scopes)
Definition: secure_credentials.cc:121
grpc_channel_args
Definition: grpc_types.h:132
grpc_core::Executor::Run
static void Run(grpc_closure *closure, grpc_error_handle error, ExecutorType executor_type=ExecutorType::DEFAULT, ExecutorJobType job_type=ExecutorJobType::SHORT)
Definition: executor.cc:398
grpc_access_token_credentials_create
GRPCAPI grpc_call_credentials * grpc_access_token_credentials_create(const char *access_token, void *reserved)
Definition: oauth2_credentials.cc:744
grpc::SecureChannelCredentials::c_creds_
grpc_channel_credentials *const c_creds_
Definition: secure_credentials.h:69
call
FilterStackCall * call
Definition: call.cc:750
grpc_ssl_credentials_create
GRPCAPI grpc_channel_credentials * grpc_ssl_credentials_create(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, const verify_peer_options *verify_options, void *reserved)
Definition: ssl_credentials.cc:132
grpc::SecureChannelCredentials::CreateChannelImpl
std::shared_ptr< Channel > CreateChannelImpl(const std::string &target, const ChannelArguments &args) override
Definition: secure_credentials.cc:63
grpc::ServiceAccountJWTAccessCredentials
std::shared_ptr< CallCredentials > ServiceAccountJWTAccessCredentials(const grpc::string &json_key, long token_lifetime_seconds=kMaxAuthTokenLifetimeSecs)
grpc_service_account_jwt_access_credentials_create
GRPCAPI grpc_call_credentials * grpc_service_account_jwt_access_credentials_create(const char *json_key, gpr_timespec token_lifetime, void *reserved)
Definition: jwt_credentials.cc:154
string_util.h
grpc_metadata
Definition: grpc_types.h:537
grpc::internal::GrpcLibraryInitializer
Instantiating this class ensures the proper initialization of gRPC.
Definition: grpcpp/impl/grpc_library.h:39
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_alts_credentials_client_options_create
GRPCAPI grpc_alts_credentials_options * grpc_alts_credentials_client_options_create(void)
Definition: grpc_alts_credentials_client_options.cc:73
GRPC_STATUS_OK
@ GRPC_STATUS_OK
Definition: include/grpc/impl/codegen/status.h:30
gpr_getenv
char * gpr_getenv(const char *name)
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
channel_arguments.h
absl::StrJoin
std::string StrJoin(Iterator start, Iterator end, absl::string_view sep, Formatter &&fmt)
Definition: abseil-cpp/absl/strings/str_join.h:239
grpc_sts_credentials_create
GRPCAPI grpc_call_credentials * grpc_sts_credentials_create(const grpc_sts_credentials_options *options, void *reserved)
Definition: oauth2_credentials.cc:701
grpc::SslCredentialsOptions
Options used to build SslCredentials.
Definition: include/grpcpp/security/credentials.h:156
grpc::experimental::LocalCredentials
std::shared_ptr< ChannelCredentials > LocalCredentials(grpc_local_connect_type type)
Builds Local Credentials.
Definition: secure_credentials.cc:309
grpc_external_account_credentials_create
GRPCAPI grpc_call_credentials * grpc_external_account_credentials_create(const char *json_string, const char *scopes_string)
Definition: external_account_credentials.cc:539
grpc::SecureCallCredentials::c_creds_
grpc_call_credentials *const c_creds_
Definition: secure_credentials.h:89
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_alts_credentials_client_options_add_target_service_account
GRPCAPI void grpc_alts_credentials_client_options_add_target_service_account(grpc_alts_credentials_options *options, const char *service_account)
Definition: grpc_alts_credentials_client_options.cc:45
grpc.StatusCode.NOT_FOUND
tuple NOT_FOUND
Definition: src/python/grpcio/grpc/__init__.py:266
grpc_metadata::value
grpc_slice value
Definition: grpc_types.h:541
grpc_call
struct grpc_call grpc_call
Definition: grpc_types.h:70
grpc::experimental::StsCredentialsCppToCoreOptions
grpc_sts_credentials_options StsCredentialsCppToCoreOptions(const StsCredentialsOptions &options)
Definition: secure_credentials.cc:255
call_creds
void call_creds(grpc_end2end_test_config config)
Definition: call_creds.cc:523
grpc::MetadataCredentialsPluginWrapper::Destroy
static void Destroy(void *wrapper)
Definition: secure_credentials.cc:433
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: include/grpc/impl/codegen/slice.h:101
channel.h
grpc_empty_slice
GPRAPI grpc_slice grpc_empty_slice(void)
Definition: slice/slice.cc:42
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
grpc_metadata_credentials_plugin
Definition: grpc_security.h:424
error.h
grpc_composite_channel_credentials_create
GRPCAPI grpc_channel_credentials * grpc_composite_channel_credentials_create(grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds, void *reserved)
Definition: composite_credentials.cc:164
wrapper
grpc_channel_wrapper * wrapper
Definition: src/php/ext/grpc/channel.h:48
json.h
grpc::MetadataCredentialsPluginWrapper::thread_pool_
std::unique_ptr< ThreadPoolInterface > thread_pool_
Definition: secure_credentials.h:130
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
grpc::SecureChannelCredentials::AsSecureCredentials
SecureChannelCredentials * AsSecureCredentials() override
Definition: secure_credentials.h:61
grpc::MetadataCredentialsPluginWrapper::plugin_
std::unique_ptr< MetadataCredentialsPlugin > plugin_
Definition: secure_credentials.h:131
grpc_core::ExecCtx
Definition: exec_ctx.h:97
grpc::experimental::TlsChannelCredentialsOptions
Definition: tls_credentials_options.h:125
grpc::CompositeCallCredentials
std::shared_ptr< CallCredentials > CompositeCallCredentials(const std::shared_ptr< CallCredentials > &creds1, const std::shared_ptr< CallCredentials > &creds2)
Combines two call credentials objects into a composite call credentials.
Definition: secure_credentials.cc:392
executor.h
gpr_types.h
grpc_core::Json::Parse
static Json Parse(absl::string_view json_str, grpc_error_handle *error)
Definition: json_reader.cc:899
grpc::SecureCallCredentials::ApplyToCall
bool ApplyToCall(grpc_call *call) override
Apply this instance's credentials to call.
Definition: secure_credentials.cc:90
grpc_call_set_credentials
GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call *call, grpc_call_credentials *creds)
Definition: security_context.cc:46
grpc::SecureCallCredentials::GetRawCreds
grpc_call_credentials * GetRawCreds()
Definition: secure_credentials.h:79
value
const char * value
Definition: hpack_parser_table.cc:165
grpc::CreateDefaultThreadPool
ThreadPoolInterface * CreateDefaultThreadPool()
Definition: create_default_thread_pool.cc:39
grpc_alts_credentials_options
Definition: grpc_alts_credentials_options.h:35
grpc::SecureAuthContext
Definition: secure_auth_context.h:35
grpc_alts_credentials_create
GRPCAPI grpc_channel_credentials * grpc_alts_credentials_create(const grpc_alts_credentials_options *options)
Definition: alts_credentials.cc:110
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
benchmark.md
md
Definition: benchmark.py:86
grpc_channel_create
GRPCAPI grpc_channel * grpc_channel_create(const char *target, grpc_channel_credentials *creds, const grpc_channel_args *args)
Definition: chttp2_connector.cc:366
grpc_security_level
grpc_security_level
Definition: grpc_security_constants.h:131
grpc::GoogleRefreshTokenCredentials
std::shared_ptr< CallCredentials > GoogleRefreshTokenCredentials(const grpc::string &json_refresh_token)
grpc_google_refresh_token_credentials_create
GRPCAPI grpc_call_credentials * grpc_google_refresh_token_credentials_create(const char *json_refresh_token, void *reserved)
Definition: oauth2_credentials.cc:508
grpc::experimental::TlsCredentials
std::shared_ptr< ChannelCredentials > TlsCredentials(const TlsChannelCredentialsOptions &options)
Builds TLS Credentials given TLS options.
Definition: secure_credentials.cc:316
grpc_library.h
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
grpc_error_std_string
std::string grpc_error_std_string(grpc_error_handle error)
Definition: error.cc:944
alloc.h
grpc::MetadataCredentialsPluginWrapper::GetMetadata
static int GetMetadata(void *wrapper, grpc_auth_metadata_context context, grpc_credentials_plugin_metadata_cb cb, void *user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], size_t *num_creds_md, grpc_status_code *status, const char **error_details)
Definition: secure_credentials.cc:441
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
grpc::MetadataCredentialsPluginWrapper::DebugString
static char * DebugString(void *wrapper)
Definition: secure_credentials.cc:426
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
grpc.StatusCode.INVALID_ARGUMENT
tuple INVALID_ARGUMENT
Definition: src/python/grpcio/grpc/__init__.py:263
grpc_security_constants.h
grpc::experimental::StsCredentials
std::shared_ptr< CallCredentials > StsCredentials(const StsCredentialsOptions &options)
Definition: secure_credentials.cc:272
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
slice_refcount.h
GRPC_PRIVACY_AND_INTEGRITY
@ GRPC_PRIVACY_AND_INTEGRITY
Definition: grpc_security_constants.h:135
GRPC_ERROR_UNREF
#define GRPC_ERROR_UNREF(err)
Definition: error.h:262
grpc::SecureChannelCredentials
Definition: secure_credentials.h:49
grpc_auth_metadata_context_copy
GRPCAPI void grpc_auth_metadata_context_copy(grpc_auth_metadata_context *from, grpc_auth_metadata_context *to)
Definition: client_auth_filter.cc:58
gpr_strdup
GPRAPI char * gpr_strdup(const char *src)
Definition: string.cc:39
GRPC_STATUS_INTERNAL
@ GRPC_STATUS_INTERNAL
Definition: include/grpc/impl/codegen/status.h:129
internal
Definition: benchmark/test/output_test_helper.cc:20
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
grpc::experimental::AltsCredentials
std::shared_ptr< ChannelCredentials > AltsCredentials(const AltsCredentialsOptions &options)
Builds ALTS Credentials given ALTS specific options.
Definition: secure_credentials.cc:294
grpc_google_default_credentials_create
GRPCAPI grpc_channel_credentials * grpc_google_default_credentials_create(grpc_call_credentials *call_credentials)
Definition: google_default_credentials.cc:429
grpc::experimental::StsCredentialsOptions
Definition: include/grpcpp/security/credentials.h:299
grpc::AccessTokenCredentials
std::shared_ptr< CallCredentials > AccessTokenCredentials(const grpc::string &access_token)
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
cleanup
Definition: cleanup.py:1
gpr_timespec
Definition: gpr_types.h:50
json_util.h
grpc_error
Definition: error_internal.h:42
grpc_auth_metadata_context
Definition: grpc_security.h:391
grpc::internal::WrapChannelCredentials
std::shared_ptr< ChannelCredentials > WrapChannelCredentials(grpc_channel_credentials *creds)
Definition: secure_credentials.cc:96
grpc::experimental::AltsCredentialsOptions
Options used to build AltsCredentials.
Definition: include/grpcpp/security/credentials.h:327
grpc_local_connect_type
grpc_local_connect_type
Definition: grpc_security_constants.h:143
grpc::MetadataCredentialsFromPlugin
std::shared_ptr< CallCredentials > MetadataCredentialsFromPlugin(std::unique_ptr< MetadataCredentialsPlugin > plugin)
Definition: secure_credentials.cc:404
grpc_core::Json
Definition: src/core/lib/json/json.h:37
grpc::GoogleComputeEngineCredentials
std::shared_ptr< CallCredentials > GoogleComputeEngineCredentials()
Definition: secure_credentials.cc:325
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
grpc_ssl_pem_key_cert_pair
Definition: grpc_security.h:173
grpc_channel_credentials
Definition: src/core/lib/security/credentials/credentials.h:96
grpc::SecureChannelCredentials::SecureChannelCredentials
SecureChannelCredentials(grpc_channel_credentials *c_creds)
Definition: secure_credentials.cc:57
grpc_local_credentials_create
GRPCAPI grpc_channel_credentials * grpc_local_credentials_create(grpc_local_connect_type type)
Definition: local_credentials.cc:60
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
grpc_metadata::key
grpc_slice key
Definition: grpc_types.h:540
grpc_slice_unref_internal
void grpc_slice_unref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:39
status.h
gpr_time_from_seconds
GPRAPI gpr_timespec gpr_time_from_seconds(int64_t s, gpr_clock_type clock_type)
Definition: src/core/lib/gpr/time.cc:123
grpc::GoogleIAMCredentials
std::shared_ptr< CallCredentials > GoogleIAMCredentials(const grpc::string &authorization_token, const grpc::string &authority_selector)
GRPC_ERROR_IS_NONE
#define GRPC_ERROR_IS_NONE(err)
Definition: error.h:241


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:15