secure_credentials.h
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 
19 #ifndef GRPC_INTERNAL_CPP_CLIENT_SECURE_CREDENTIALS_H
20 #define GRPC_INTERNAL_CPP_CLIENT_SECURE_CREDENTIALS_H
21 
22 #include <stddef.h>
23 
24 #include <memory>
25 #include <string>
26 #include <vector>
27 
28 #include "absl/strings/str_cat.h"
29 
30 #include <grpc/grpc.h>
31 #include <grpc/grpc_security.h>
33 #include <grpc/status.h>
34 #include <grpcpp/channel.h>
39 #include <grpcpp/support/config.h>
40 // TODO(yashykt): We shouldn't be including "src/core" headers.
44 
45 namespace grpc {
46 
47 class Channel;
48 
50  public:
54  if (c_creds_ != nullptr) c_creds_->Unref();
55  }
57 
58  std::shared_ptr<Channel> CreateChannelImpl(
59  const std::string& target, const ChannelArguments& args) override;
60 
61  SecureChannelCredentials* AsSecureCredentials() override { return this; }
62 
63  private:
64  std::shared_ptr<Channel> CreateChannelWithInterceptors(
65  const std::string& target, const ChannelArguments& args,
66  std::vector<std::unique_ptr<
68  interceptor_creators) override;
70 };
71 
72 class SecureCallCredentials final : public CallCredentials {
73  public:
77  if (c_creds_ != nullptr) c_creds_->Unref();
78  }
80 
81  bool ApplyToCall(grpc_call* call) override;
82  SecureCallCredentials* AsSecureCredentials() override { return this; }
83  std::string DebugString() override {
84  return absl::StrCat("SecureCallCredentials{",
86  }
87 
88  private:
90 };
91 
92 namespace internal {
93 
94 std::shared_ptr<ChannelCredentials> WrapChannelCredentials(
96 
97 } // namespace internal
98 
99 namespace experimental {
100 
101 // Transforms C++ STS Credentials options to core options. The pointers of the
102 // resulting core options point to the memory held by the C++ options so C++
103 // options need to be kept alive until after the core credentials creation.
105  const StsCredentialsOptions& options);
106 
107 } // namespace experimental
108 
110  public:
111  static void Destroy(void* wrapper);
112  static int GetMetadata(
114  grpc_credentials_plugin_metadata_cb cb, void* user_data,
116  size_t* num_creds_md, grpc_status_code* status,
117  const char** error_details);
118  static char* DebugString(void* wrapper);
119 
121  std::unique_ptr<MetadataCredentialsPlugin> plugin);
122 
123  private:
124  void InvokePlugin(
126  grpc_credentials_plugin_metadata_cb cb, void* user_data,
128  size_t* num_creds_md, grpc_status_code* status_code,
129  const char** error_details);
130  std::unique_ptr<ThreadPoolInterface> thread_pool_;
131  std::unique_ptr<MetadataCredentialsPlugin> plugin_;
132 };
133 
134 } // namespace grpc
135 
136 #endif // GRPC_INTERNAL_CPP_CLIENT_SECURE_CREDENTIALS_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_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
grpc::SecureChannelCredentials::GetRawCreds
grpc_channel_credentials * GetRawCreds()
Definition: secure_credentials.h:56
grpc::SecureCallCredentials::SecureCallCredentials
SecureCallCredentials(grpc_call_credentials *c_creds)
Definition: secure_credentials.cc:85
absl::StrCat
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: abseil-cpp/absl/strings/str_cat.cc:98
grpc
Definition: grpcpp/alarm.h:33
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::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::MetadataCredentialsPluginWrapper
Definition: secure_credentials.h:109
grpc::experimental::ClientInterceptorFactoryInterface
Definition: impl/codegen/client_interceptor.h:48
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
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
grpc_call_credentials
Definition: src/core/lib/security/credentials/credentials.h:189
grpc::SecureCallCredentials::AsSecureCredentials
SecureCallCredentials * AsSecureCredentials() override
Definition: secure_credentials.h:82
grpc::SecureCallCredentials
Definition: secure_credentials.h:72
grpc_security.h
grpc::ChannelCredentials
Definition: include/grpcpp/security/credentials.h:75
grpc::GrpcLibraryCodegen
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpcpp/impl/codegen/grpc_library.h:40
credentials.h
grpc::SecureChannelCredentials::c_creds_
grpc_channel_credentials *const c_creds_
Definition: secure_credentials.h:69
call
FilterStackCall * call
Definition: call.cc:750
grpc::SecureChannelCredentials::CreateChannelImpl
std::shared_ptr< Channel > CreateChannelImpl(const std::string &target, const ChannelArguments &args) override
Definition: secure_credentials.cc:63
status.h
grpc_types.h
grpc_core::RefCounted::Unref
void Unref()
Definition: ref_counted.h:302
grpc_metadata
Definition: grpc_types.h:537
grpc::SecureChannelCredentials::~SecureChannelCredentials
~SecureChannelCredentials() override
Definition: secure_credentials.h:52
framework.rpc.grpc_channelz.Channel
Channel
Definition: grpc_channelz.py:32
client_interceptor.h
thread_pool_interface.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
channel_arguments.h
grpc::SecureCallCredentials::c_creds_
grpc_call_credentials *const c_creds_
Definition: secure_credentials.h:89
grpc::SecureCallCredentials::~SecureCallCredentials
~SecureCallCredentials() override
Definition: secure_credentials.h:75
grpc.h
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
grpc::MetadataCredentialsPluginWrapper::Destroy
static void Destroy(void *wrapper)
Definition: secure_credentials.cc:433
channel.h
wrapper
grpc_channel_wrapper * wrapper
Definition: src/php/ext/grpc/channel.h:48
grpc::MetadataCredentialsPluginWrapper::thread_pool_
std::unique_ptr< ThreadPoolInterface > thread_pool_
Definition: secure_credentials.h:130
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
config.h
grpc::SecureCallCredentials::ApplyToCall
bool ApplyToCall(grpc_call *call) override
Apply this instance's credentials to call.
Definition: secure_credentials.cc:90
grpc::SecureCallCredentials::GetRawCreds
grpc_call_credentials * GetRawCreds()
Definition: secure_credentials.h:79
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
credentials.h
grpc_library.h
exec_ctx
grpc_core::ExecCtx exec_ctx
Definition: end2end_binder_transport_test.cc:75
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
grpc::MetadataCredentialsPluginWrapper::DebugString
static char * DebugString(void *wrapper)
Definition: secure_credentials.cc:426
exec_ctx.h
grpc::SecureChannelCredentials
Definition: secure_credentials.h:49
internal
Definition: benchmark/test/output_test_helper.cc:20
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
grpc::SecureCallCredentials::DebugString
std::string DebugString() override
Definition: secure_credentials.h:83
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
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::CallCredentials
Definition: include/grpcpp/security/credentials.h:132
grpc::SecureChannelCredentials::SecureChannelCredentials
SecureChannelCredentials(grpc_channel_credentials *c_creds)
Definition: secure_credentials.cc:57
cb
OPENSSL_EXPORT pem_password_cb * cb
Definition: pem.h:351
grpc_call_credentials::debug_string
virtual std::string debug_string()
Definition: src/core/lib/security/credentials/credentials.h:231


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