GRPC Core  9.0.0
google_default_credentials.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 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 
19 #ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H
20 #define GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H
21 
23 
26 
27 #define GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY "gcloud"
28 #define GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE \
29  "application_default_credentials.json"
30 
31 #ifdef GPR_WINDOWS
32 #define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "APPDATA"
33 #define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \
34  GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \
35  "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE
36 #else
37 #define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "HOME"
38 #define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \
39  ".config/" GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \
40  "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE
41 #endif
42 
44  : public grpc_channel_credentials {
45  public:
50  alts_creds_(std::move(alts_creds)),
51  ssl_creds_(std::move(ssl_creds)) {}
52 
53  ~grpc_google_default_channel_credentials() override = default;
54 
58  const char* target, const grpc_channel_args* args,
59  grpc_channel_args** new_args) override;
60 
62 
64  return alts_creds_.get();
65  }
66  const grpc_channel_credentials* ssl_creds() const { return ssl_creds_.get(); }
67 
68  private:
71 };
72 
73 namespace grpc_core {
74 namespace internal {
75 
76 typedef bool (*grpc_gce_tenancy_checker)(void);
77 
79 
80 // TEST-ONLY. Reset the internal global state.
82 
83 } // namespace internal
84 } // namespace grpc_core
85 
86 #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \
87  */
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: credentials.h:99
Definition: google_default_credentials.h:43
~grpc_google_default_channel_credentials() override=default
Round Robin Policy.
Definition: backend_metric.cc:24
grpc_google_default_channel_credentials(grpc_core::RefCountedPtr< grpc_channel_credentials > alts_creds, grpc_core::RefCountedPtr< grpc_channel_credentials > ssl_creds)
Definition: google_default_credentials.h:46
grpc_core::RefCountedPtr< grpc_channel_security_connector > create_security_connector(grpc_core::RefCountedPtr< grpc_call_credentials > call_creds, const char *target, const grpc_channel_args *args, grpc_channel_args **new_args) override
Definition: google_default_credentials.cc:77
bool(* grpc_gce_tenancy_checker)(void)
Definition: google_default_credentials.h:76
T * get() const
Definition: ref_counted_ptr.h:144
void grpc_flush_cached_google_default_credentials(void)
Definition: google_default_credentials.cc:363
#define GRPC_CHANNEL_CREDENTIALS_TYPE_GOOGLE_DEFAULT
Definition: credentials.h:51
const grpc_channel_credentials * alts_creds() const
Definition: google_default_credentials.h:63
grpc_channel_args * update_arguments(grpc_channel_args *args) override
Definition: google_default_credentials.cc:117
void set_gce_tenancy_checker_for_testing(grpc_gce_tenancy_checker checker)
Definition: google_default_credentials.cc:359
const grpc_channel_credentials * ssl_creds() const
Definition: google_default_credentials.h:66