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
22 
23 #include <utility>
24 
25 #include <grpc/grpc.h>
26 #include <grpc/grpc_security.h>
28 
35 
36 #define GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY "gcloud"
37 #define GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE \
38  "application_default_credentials.json"
39 
40 #ifdef GPR_WINDOWS
41 #define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "APPDATA"
42 #define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \
43  GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \
44  "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE
45 #else
46 #define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "HOME"
47 #define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \
48  ".config/" GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \
49  "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE
50 #endif
51 
53  : public grpc_channel_credentials {
54  public:
59 
60  ~grpc_google_default_channel_credentials() override = default;
61 
65  const char* target, const grpc_channel_args* args,
66  grpc_channel_args** new_args) override;
67 
69 
70  grpc_core::UniqueTypeName type() const override;
71 
73  return alts_creds_.get();
74  }
75  const grpc_channel_credentials* ssl_creds() const { return ssl_creds_.get(); }
76 
77  private:
78  int cmp_impl(const grpc_channel_credentials* other) const override {
79  // TODO(yashykt): Check if we can do something better here
81  static_cast<const grpc_channel_credentials*>(this), other);
82  }
83 
86 };
87 
88 namespace grpc_core {
89 namespace internal {
90 
91 typedef bool (*grpc_gce_tenancy_checker)(void);
92 
94 
95 // TEST-ONLY. Reset the internal global state.
97 
98 } // namespace internal
99 } // namespace grpc_core
100 
101 #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \
102  */
grpc_google_default_channel_credentials::ssl_creds_
grpc_core::RefCountedPtr< grpc_channel_credentials > ssl_creds_
Definition: google_default_credentials.h:85
bool
bool
Definition: setup_once.h:312
grpc_google_default_channel_credentials::type
grpc_core::UniqueTypeName type() const override
Definition: google_default_credentials.cc:166
grpc_core::internal::set_gce_tenancy_checker_for_testing
void set_gce_tenancy_checker_for_testing(grpc_gce_tenancy_checker checker)
Definition: google_default_credentials.cc:471
grpc_core::RefCountedPtr::get
T * get() const
Definition: ref_counted_ptr.h:146
grpc_core
Definition: call_metric_recorder.h:31
grpc_google_default_channel_credentials::ssl_creds
const grpc_channel_credentials * ssl_creds() const
Definition: google_default_credentials.h:75
useful.h
grpc_security.h
grpc_google_default_channel_credentials::alts_creds
const grpc_channel_credentials * alts_creds() const
Definition: google_default_credentials.h:72
credentials.h
grpc_channel_args
Definition: grpc_types.h:132
grpc_google_default_channel_credentials
Definition: google_default_credentials.h:52
grpc_types.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_core::RefCountedPtr< grpc_channel_credentials >
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
grpc_google_default_channel_credentials::grpc_google_default_channel_credentials
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:55
grpc_core::internal::grpc_gce_tenancy_checker
bool(* grpc_gce_tenancy_checker)(void)
Definition: google_default_credentials.h:91
grpc.h
security_connector.h
call_creds
void call_creds(grpc_end2end_test_config config)
Definition: call_creds.cc:523
grpc_google_default_channel_credentials::update_arguments
grpc_core::ChannelArgs update_arguments(grpc_core::ChannelArgs args) override
Definition: google_default_credentials.cc:161
grpc_google_default_channel_credentials::cmp_impl
int cmp_impl(const grpc_channel_credentials *other) const override
Definition: google_default_credentials.h:78
grpc_core::UniqueTypeName
Definition: unique_type_name.h:56
grpc_google_default_channel_credentials::create_security_connector
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:120
grpc_core::QsortCompare
int QsortCompare(const T &a, const T &b)
Definition: useful.h:95
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
unique_type_name.h
grpc_core::ChannelArgs
Definition: channel_args.h:111
ref_counted_ptr.h
channel_args.h
internal
Definition: benchmark/test/output_test_helper.cc:20
grpc_core::internal::grpc_flush_cached_google_default_credentials
void grpc_flush_cached_google_default_credentials(void)
Definition: google_default_credentials.cc:475
grpc_google_default_channel_credentials::alts_creds_
grpc_core::RefCountedPtr< grpc_channel_credentials > alts_creds_
Definition: google_default_credentials.h:84
setup.target
target
Definition: third_party/bloaty/third_party/protobuf/python/setup.py:179
grpc_channel_credentials
Definition: src/core/lib/security/credentials/credentials.h:96
grpc_google_default_channel_credentials::~grpc_google_default_channel_credentials
~grpc_google_default_channel_credentials() override=default
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:40