summaryrefslogtreecommitdiff
path: root/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
diff options
context:
space:
mode:
authorJoel Galenson <jgalenson@google.com>2021-04-20 16:03:38 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-04-20 16:03:38 +0000
commit213f77c31038c4b09e2235bcdde42416517d08b9 (patch)
tree9ff33245fc40085284a777f947a77028b4a715f5 /grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
parent14e82ce9828dc1295f579e168cfd9501614ef102 (diff)
parent324f6f886c21553b93ce22e3e17f94676ef05f62 (diff)
downloadgrpcio-sys-213f77c31038c4b09e2235bcdde42416517d08b9.tar.gz
Upgrade rust/crates/grpcio-sys to 0.8.1 am: 23c9e5ee44 am: 03b0fdb0d7 am: c0c548f475 am: 324f6f886c
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/grpcio-sys/+/1662764 Change-Id: I5e734392a695d8ce7b1caa403fecebb1ff35a932
Diffstat (limited to 'grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc')
-rw-r--r--grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
index 9162bad4..d1de87db 100644
--- a/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
+++ b/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.cc
@@ -27,6 +27,7 @@
#include <grpc/support/sync.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
+#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/gpr/string.h"
@@ -37,6 +38,7 @@
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/security/credentials/alts/alts_credentials.h"
#include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
+#include "src/core/lib/security/credentials/external/external_account_credentials.h"
#include "src/core/lib/security/credentials/google_default/google_default_credentials.h"
#include "src/core/lib/security/credentials/jwt/jwt_credentials.h"
#include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h"
@@ -80,21 +82,22 @@ grpc_google_default_channel_credentials::create_security_connector(
grpc_core::RefCountedPtr<grpc_call_credentials> call_creds,
const char* target, const grpc_channel_args* args,
grpc_channel_args** new_args) {
- bool is_grpclb_load_balancer = grpc_channel_arg_get_bool(
- grpc_channel_args_find(args, GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER),
- false);
- bool is_backend_from_grpclb_load_balancer = grpc_channel_arg_get_bool(
- grpc_channel_args_find(
- args, GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER),
- false);
- bool use_alts =
- is_grpclb_load_balancer || is_backend_from_grpclb_load_balancer;
+ const bool is_grpclb_load_balancer = grpc_channel_args_find_bool(
+ args, GRPC_ARG_ADDRESS_IS_GRPCLB_LOAD_BALANCER, false);
+ const bool is_backend_from_grpclb_load_balancer = grpc_channel_args_find_bool(
+ args, GRPC_ARG_ADDRESS_IS_BACKEND_FROM_GRPCLB_LOAD_BALANCER, false);
+ const char* xds_cluster =
+ grpc_channel_args_find_string(args, GRPC_ARG_XDS_CLUSTER_NAME);
+ const bool is_xds_non_cfe_cluster =
+ xds_cluster != nullptr && strcmp(xds_cluster, "google_cfe") != 0;
+ const bool use_alts = is_grpclb_load_balancer ||
+ is_backend_from_grpclb_load_balancer ||
+ is_xds_non_cfe_cluster;
/* Return failure if ALTS is selected but not running on GCE. */
if (use_alts && alts_creds_ == nullptr) {
gpr_log(GPR_ERROR, "ALTS is selected, but not running on GCE.");
return nullptr;
}
-
grpc_core::RefCountedPtr<grpc_channel_security_connector> sc =
use_alts ? alts_creds_->create_security_connector(call_creds, target,
args, new_args)
@@ -175,8 +178,8 @@ static int is_metadata_server_reachable() {
detector.is_done = 0;
detector.success = 0;
memset(&request, 0, sizeof(grpc_httpcli_request));
- request.host = (char*)GRPC_COMPUTE_ENGINE_DETECTION_HOST;
- request.http.path = (char*)"/";
+ request.host = const_cast<char*>(GRPC_COMPUTE_ENGINE_DETECTION_HOST);
+ request.http.path = const_cast<char*>("/");
grpc_httpcli_context_init(&context);
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("google_default_credentials");
@@ -267,6 +270,9 @@ static grpc_error* create_default_creds_from_path(
goto end;
}
+ /* Finally try an external account credentials.*/
+ result = grpc_core::ExternalAccountCredentials::Create(json, {}, &error);
+
end:
GPR_ASSERT((result == nullptr) + (error == GRPC_ERROR_NONE) == 1);
grpc_slice_unref_internal(creds_data);