aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-12-01 22:40:44 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-12-01 22:40:44 +0100
commitf9c58f3bf71a7ce1a2fbbb04a7f9766735522778 (patch)
tree644e1c222f7ce8d5190a357d5da6e13a1edb50f3 /src/cpp
parentcf42611b39b08fc4e9864a5e1b37bcfeef8522bb (diff)
parent3e5cbee777cfd1d05f1161dfb97093878c7e48ed (diff)
Merge branch 'release-0_12'
Conflicts: src/core/security/credentials.c test/core/security/credentials_test.c
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/client/secure_credentials.cc23
-rw-r--r--src/cpp/client/secure_credentials.h4
2 files changed, 18 insertions, 9 deletions
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index a1b9a3018e..6409323262 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -37,6 +37,7 @@
#include <grpc++/support/channel_arguments.h>
#include "src/cpp/client/create_channel_internal.h"
#include "src/cpp/client/secure_credentials.h"
+#include "src/cpp/common/secure_auth_context.h"
namespace grpc {
@@ -160,7 +161,7 @@ void MetadataCredentialsPluginWrapper::Destroy(void* wrapper) {
}
void MetadataCredentialsPluginWrapper::GetMetadata(
- void* wrapper, const char* service_url,
+ void* wrapper, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, void* user_data) {
GPR_ASSERT(wrapper);
MetadataCredentialsPluginWrapper* w =
@@ -171,18 +172,25 @@ void MetadataCredentialsPluginWrapper::GetMetadata(
}
if (w->plugin_->IsBlocking()) {
w->thread_pool_->Add(
- std::bind(&MetadataCredentialsPluginWrapper::InvokePlugin, w,
- service_url, cb, user_data));
+ std::bind(&MetadataCredentialsPluginWrapper::InvokePlugin, w, context,
+ cb, user_data));
} else {
- w->InvokePlugin(service_url, cb, user_data);
+ w->InvokePlugin(context, cb, user_data);
}
}
void MetadataCredentialsPluginWrapper::InvokePlugin(
- const char* service_url, grpc_credentials_plugin_metadata_cb cb,
+ grpc_auth_metadata_context context, grpc_credentials_plugin_metadata_cb cb,
void* user_data) {
std::multimap<grpc::string, grpc::string> metadata;
- Status status = plugin_->GetMetadata(service_url, &metadata);
+
+ // const_cast is safe since the SecureAuthContext does not take owndership and
+ // the object is passed as a const ref to plugin_->GetMetadata.
+ SecureAuthContext cpp_channel_auth_context(
+ const_cast<grpc_auth_context*>(context.channel_auth_context), false);
+
+ Status status = plugin_->GetMetadata(context.service_url, context.method_name,
+ cpp_channel_auth_context, &metadata);
std::vector<grpc_metadata> md;
for (auto it = metadata.begin(); it != metadata.end(); ++it) {
grpc_metadata md_entry;
@@ -204,11 +212,12 @@ MetadataCredentialsPluginWrapper::MetadataCredentialsPluginWrapper(
std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
std::unique_ptr<MetadataCredentialsPlugin> plugin) {
GrpcLibrary init; // To call grpc_init().
+ const char* type = plugin->GetType();
MetadataCredentialsPluginWrapper* wrapper =
new MetadataCredentialsPluginWrapper(std::move(plugin));
grpc_metadata_credentials_plugin c_plugin = {
MetadataCredentialsPluginWrapper::GetMetadata,
- MetadataCredentialsPluginWrapper::Destroy, wrapper};
+ MetadataCredentialsPluginWrapper::Destroy, wrapper, type};
return WrapCallCredentials(
grpc_metadata_credentials_create_from_plugin(c_plugin, nullptr));
}
diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h
index e9afa9e57f..cef59292dd 100644
--- a/src/cpp/client/secure_credentials.h
+++ b/src/cpp/client/secure_credentials.h
@@ -79,7 +79,7 @@ class SecureCallCredentials GRPC_FINAL : public CallCredentials {
class MetadataCredentialsPluginWrapper GRPC_FINAL {
public:
static void Destroy(void* wrapper);
- static void GetMetadata(void* wrapper, const char* service_url,
+ static void GetMetadata(void* wrapper, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb,
void* user_data);
@@ -87,7 +87,7 @@ class MetadataCredentialsPluginWrapper GRPC_FINAL {
std::unique_ptr<MetadataCredentialsPlugin> plugin);
private:
- void InvokePlugin(const char* service_url,
+ void InvokePlugin(grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, void* user_data);
std::unique_ptr<ThreadPoolInterface> thread_pool_;
std::unique_ptr<MetadataCredentialsPlugin> plugin_;