aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/client/channel.cc2
-rw-r--r--src/cpp/client/client_context.cc2
-rw-r--r--src/cpp/client/create_channel.cc7
-rw-r--r--src/cpp/client/credentials.cc2
-rw-r--r--src/cpp/client/insecure_credentials.cc2
-rw-r--r--src/cpp/client/secure_credentials.cc45
-rw-r--r--src/cpp/client/secure_credentials.h2
-rw-r--r--src/cpp/common/auth_property_iterator.cc8
-rw-r--r--src/cpp/common/create_auth_context.h2
-rw-r--r--src/cpp/common/insecure_create_auth_context.cc2
-rw-r--r--src/cpp/common/secure_auth_context.cc42
-rw-r--r--src/cpp/common/secure_auth_context.h19
-rw-r--r--src/cpp/common/secure_create_auth_context.cc4
-rw-r--r--src/cpp/server/insecure_server_credentials.cc8
-rw-r--r--src/cpp/server/secure_server_credentials.cc81
-rw-r--r--src/cpp/server/secure_server_credentials.h32
-rw-r--r--src/cpp/server/server.cc6
-rw-r--r--src/cpp/server/server_credentials.cc2
-rw-r--r--src/cpp/util/string_ref.cc3
19 files changed, 204 insertions, 67 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index 8bf2e4687e..dc8e304664 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -40,7 +40,7 @@
#include <grpc/support/slice.h>
#include <grpc++/client_context.h>
#include <grpc++/completion_queue.h>
-#include <grpc++/credentials.h>
+#include <grpc++/security/credentials.h>
#include <grpc++/impl/call.h>
#include <grpc++/impl/rpc_method.h>
#include <grpc++/support/channel_arguments.h>
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index c4d7cf2e51..574656a7e9 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -36,7 +36,7 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
-#include <grpc++/credentials.h>
+#include <grpc++/security/credentials.h>
#include <grpc++/server_context.h>
#include <grpc++/support/time.h>
diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc
index 8c571cbbaa..d2b2d30126 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -44,8 +44,14 @@ namespace grpc {
class ChannelArguments;
std::shared_ptr<Channel> CreateChannel(
+ const grpc::string& target, const std::shared_ptr<Credentials>& creds) {
+ return CreateCustomChannel(target, creds, ChannelArguments());
+}
+
+std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target, const std::shared_ptr<Credentials>& creds,
const ChannelArguments& args) {
+ GrpcLibrary init_lib; // We need to call init in case of a bad creds.
ChannelArguments cp_args = args;
std::ostringstream user_agent_prefix;
user_agent_prefix << "grpc-c++/" << grpc_version_string();
@@ -57,4 +63,5 @@ std::shared_ptr<Channel> CreateChannel(
NULL, GRPC_STATUS_INVALID_ARGUMENT,
"Invalid credentials."));
}
+
} // namespace grpc
diff --git a/src/cpp/client/credentials.cc b/src/cpp/client/credentials.cc
index e806284988..7a8149e9c7 100644
--- a/src/cpp/client/credentials.cc
+++ b/src/cpp/client/credentials.cc
@@ -31,7 +31,7 @@
*
*/
-#include <grpc++/credentials.h>
+#include <grpc++/security/credentials.h>
namespace grpc {
diff --git a/src/cpp/client/insecure_credentials.cc b/src/cpp/client/insecure_credentials.cc
index 4a4d2cb97d..c476f3ce95 100644
--- a/src/cpp/client/insecure_credentials.cc
+++ b/src/cpp/client/insecure_credentials.cc
@@ -31,7 +31,7 @@
*
*/
-#include <grpc++/credentials.h>
+#include <grpc++/security/credentials.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index f368f2590a..2260f6d33e 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -46,7 +46,8 @@ std::shared_ptr<grpc::Channel> SecureCredentials::CreateChannel(
args.SetChannelArgs(&channel_args);
return CreateChannelInternal(
args.GetSslTargetNameOverride(),
- grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args));
+ grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args,
+ nullptr));
}
bool SecureCredentials::ApplyToCall(grpc_call* call) {
@@ -75,31 +76,15 @@ std::shared_ptr<Credentials> SslCredentials(
grpc_credentials* c_creds = grpc_ssl_credentials_create(
options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(),
- options.pem_private_key.empty() ? nullptr : &pem_key_cert_pair);
+ options.pem_private_key.empty() ? nullptr : &pem_key_cert_pair, nullptr);
return WrapCredentials(c_creds);
}
// Builds credentials for use when running in GCE
-std::shared_ptr<Credentials> ComputeEngineCredentials() {
+std::shared_ptr<Credentials> GoogleComputeEngineCredentials() {
GrpcLibrary init; // To call grpc_init().
- return WrapCredentials(grpc_compute_engine_credentials_create());
-}
-
-// Builds service account credentials.
-std::shared_ptr<Credentials> ServiceAccountCredentials(
- const grpc::string& json_key, const grpc::string& scope,
- long token_lifetime_seconds) {
- GrpcLibrary init; // To call grpc_init().
- if (token_lifetime_seconds <= 0) {
- gpr_log(GPR_ERROR,
- "Trying to create ServiceAccountCredentials "
- "with non-positive lifetime");
- return WrapCredentials(nullptr);
- }
- gpr_timespec lifetime =
- gpr_time_from_seconds(token_lifetime_seconds, GPR_TIMESPAN);
- return WrapCredentials(grpc_service_account_credentials_create(
- json_key.c_str(), scope.c_str(), lifetime));
+ return WrapCredentials(
+ grpc_google_compute_engine_credentials_create(nullptr));
}
// Builds JWT credentials.
@@ -114,15 +99,15 @@ std::shared_ptr<Credentials> ServiceAccountJWTAccessCredentials(
gpr_timespec lifetime =
gpr_time_from_seconds(token_lifetime_seconds, GPR_TIMESPAN);
return WrapCredentials(grpc_service_account_jwt_access_credentials_create(
- json_key.c_str(), lifetime));
+ json_key.c_str(), lifetime, nullptr));
}
// Builds refresh token credentials.
-std::shared_ptr<Credentials> RefreshTokenCredentials(
+std::shared_ptr<Credentials> GoogleRefreshTokenCredentials(
const grpc::string& json_refresh_token) {
GrpcLibrary init; // To call grpc_init().
- return WrapCredentials(
- grpc_refresh_token_credentials_create(json_refresh_token.c_str()));
+ return WrapCredentials(grpc_google_refresh_token_credentials_create(
+ json_refresh_token.c_str(), nullptr));
}
// Builds access token credentials.
@@ -130,16 +115,16 @@ std::shared_ptr<Credentials> AccessTokenCredentials(
const grpc::string& access_token) {
GrpcLibrary init; // To call grpc_init().
return WrapCredentials(
- grpc_access_token_credentials_create(access_token.c_str()));
+ grpc_access_token_credentials_create(access_token.c_str(), nullptr));
}
// Builds IAM credentials.
-std::shared_ptr<Credentials> IAMCredentials(
+std::shared_ptr<Credentials> GoogleIAMCredentials(
const grpc::string& authorization_token,
const grpc::string& authority_selector) {
GrpcLibrary init; // To call grpc_init().
- return WrapCredentials(grpc_iam_credentials_create(
- authorization_token.c_str(), authority_selector.c_str()));
+ return WrapCredentials(grpc_google_iam_credentials_create(
+ authorization_token.c_str(), authority_selector.c_str(), nullptr));
}
// Combines two credentials objects into a composite credentials.
@@ -154,7 +139,7 @@ std::shared_ptr<Credentials> CompositeCredentials(
SecureCredentials* s2 = creds2->AsSecureCredentials();
if (s1 && s2) {
return WrapCredentials(grpc_composite_credentials_create(
- s1->GetRawCreds(), s2->GetRawCreds()));
+ s1->GetRawCreds(), s2->GetRawCreds(), nullptr));
}
return nullptr;
}
diff --git a/src/cpp/client/secure_credentials.h b/src/cpp/client/secure_credentials.h
index 62d3185477..8deff856c4 100644
--- a/src/cpp/client/secure_credentials.h
+++ b/src/cpp/client/secure_credentials.h
@@ -37,7 +37,7 @@
#include <grpc/grpc_security.h>
#include <grpc++/support/config.h>
-#include <grpc++/credentials.h>
+#include <grpc++/security/credentials.h>
namespace grpc {
diff --git a/src/cpp/common/auth_property_iterator.cc b/src/cpp/common/auth_property_iterator.cc
index 5ccf8cf72c..a47abaf4b8 100644
--- a/src/cpp/common/auth_property_iterator.cc
+++ b/src/cpp/common/auth_property_iterator.cc
@@ -31,7 +31,7 @@
*
*/
-#include <grpc++/support/auth_context.h>
+#include <grpc++/security/auth_context.h>
#include <grpc/grpc_security.h>
@@ -77,9 +77,9 @@ bool AuthPropertyIterator::operator!=(const AuthPropertyIterator& rhs) const {
}
const AuthProperty AuthPropertyIterator::operator*() {
- return std::make_pair<grpc::string, grpc::string>(
- grpc::string(property_->name),
- grpc::string(property_->value, property_->value_length));
+ return std::pair<grpc::string_ref, grpc::string_ref>(
+ property_->name,
+ grpc::string_ref(property_->value, property_->value_length));
}
} // namespace grpc
diff --git a/src/cpp/common/create_auth_context.h b/src/cpp/common/create_auth_context.h
index b4962bae4e..4f3da397ba 100644
--- a/src/cpp/common/create_auth_context.h
+++ b/src/cpp/common/create_auth_context.h
@@ -33,7 +33,7 @@
#include <memory>
#include <grpc/grpc.h>
-#include <grpc++/support/auth_context.h>
+#include <grpc++/security/auth_context.h>
namespace grpc {
diff --git a/src/cpp/common/insecure_create_auth_context.cc b/src/cpp/common/insecure_create_auth_context.cc
index fe80c1a80c..b2e153229a 100644
--- a/src/cpp/common/insecure_create_auth_context.cc
+++ b/src/cpp/common/insecure_create_auth_context.cc
@@ -33,7 +33,7 @@
#include <memory>
#include <grpc/grpc.h>
-#include <grpc++/support/auth_context.h>
+#include <grpc++/security/auth_context.h>
namespace grpc {
diff --git a/src/cpp/common/secure_auth_context.cc b/src/cpp/common/secure_auth_context.cc
index 87d7bab75c..8615ac8aeb 100644
--- a/src/cpp/common/secure_auth_context.cc
+++ b/src/cpp/common/secure_auth_context.cc
@@ -37,19 +37,24 @@
namespace grpc {
-SecureAuthContext::SecureAuthContext(grpc_auth_context* ctx) : ctx_(ctx) {}
+SecureAuthContext::SecureAuthContext(grpc_auth_context* ctx,
+ bool take_ownership)
+ : ctx_(ctx), take_ownership_(take_ownership) {}
-SecureAuthContext::~SecureAuthContext() { grpc_auth_context_release(ctx_); }
+SecureAuthContext::~SecureAuthContext() {
+ if (take_ownership_) grpc_auth_context_release(ctx_);
+}
-std::vector<grpc::string> SecureAuthContext::GetPeerIdentity() const {
+std::vector<grpc::string_ref> SecureAuthContext::GetPeerIdentity() const {
if (!ctx_) {
- return std::vector<grpc::string>();
+ return std::vector<grpc::string_ref>();
}
grpc_auth_property_iterator iter = grpc_auth_context_peer_identity(ctx_);
- std::vector<grpc::string> identity;
+ std::vector<grpc::string_ref> identity;
const grpc_auth_property* property = nullptr;
while ((property = grpc_auth_property_iterator_next(&iter))) {
- identity.push_back(grpc::string(property->value, property->value_length));
+ identity.push_back(
+ grpc::string_ref(property->value, property->value_length));
}
return identity;
}
@@ -62,17 +67,17 @@ grpc::string SecureAuthContext::GetPeerIdentityPropertyName() const {
return name == nullptr ? "" : name;
}
-std::vector<grpc::string> SecureAuthContext::FindPropertyValues(
+std::vector<grpc::string_ref> SecureAuthContext::FindPropertyValues(
const grpc::string& name) const {
if (!ctx_) {
- return std::vector<grpc::string>();
+ return std::vector<grpc::string_ref>();
}
grpc_auth_property_iterator iter =
grpc_auth_context_find_properties_by_name(ctx_, name.c_str());
const grpc_auth_property* property = nullptr;
- std::vector<grpc::string> values;
+ std::vector<grpc::string_ref> values;
while ((property = grpc_auth_property_iterator_next(&iter))) {
- values.push_back(grpc::string(property->value, property->value_length));
+ values.push_back(grpc::string_ref(property->value, property->value_length));
}
return values;
}
@@ -93,4 +98,21 @@ AuthPropertyIterator SecureAuthContext::end() const {
return AuthPropertyIterator();
}
+void SecureAuthContext::AddProperty(const grpc::string& key,
+ const grpc::string_ref& value) {
+ if (!ctx_) return;
+ grpc_auth_context_add_property(ctx_, key.c_str(), value.data(), value.size());
+}
+
+bool SecureAuthContext::SetPeerIdentityPropertyName(const grpc::string& name) {
+ if (!ctx_) return false;
+ return grpc_auth_context_set_peer_identity_property_name(ctx_,
+ name.c_str()) != 0;
+}
+
+bool SecureAuthContext::IsPeerAuthenticated() const {
+ if (!ctx_) return false;
+ return grpc_auth_context_peer_is_authenticated(ctx_) != 0;
+}
+
} // namespace grpc
diff --git a/src/cpp/common/secure_auth_context.h b/src/cpp/common/secure_auth_context.h
index 01b7126189..c9f1dad131 100644
--- a/src/cpp/common/secure_auth_context.h
+++ b/src/cpp/common/secure_auth_context.h
@@ -34,7 +34,7 @@
#ifndef GRPC_INTERNAL_CPP_COMMON_SECURE_AUTH_CONTEXT_H
#define GRPC_INTERNAL_CPP_COMMON_SECURE_AUTH_CONTEXT_H
-#include <grpc++/support/auth_context.h>
+#include <grpc++/security/auth_context.h>
struct grpc_auth_context;
@@ -42,23 +42,32 @@ namespace grpc {
class SecureAuthContext GRPC_FINAL : public AuthContext {
public:
- SecureAuthContext(grpc_auth_context* ctx);
+ SecureAuthContext(grpc_auth_context* ctx, bool take_ownership);
~SecureAuthContext() GRPC_OVERRIDE;
- std::vector<grpc::string> GetPeerIdentity() const GRPC_OVERRIDE;
+ bool IsPeerAuthenticated() const GRPC_OVERRIDE;
+
+ std::vector<grpc::string_ref> GetPeerIdentity() const GRPC_OVERRIDE;
grpc::string GetPeerIdentityPropertyName() const GRPC_OVERRIDE;
- std::vector<grpc::string> FindPropertyValues(const grpc::string& name) const
- GRPC_OVERRIDE;
+ std::vector<grpc::string_ref> FindPropertyValues(
+ const grpc::string& name) const GRPC_OVERRIDE;
AuthPropertyIterator begin() const GRPC_OVERRIDE;
AuthPropertyIterator end() const GRPC_OVERRIDE;
+ void AddProperty(const grpc::string& key,
+ const grpc::string_ref& value) GRPC_OVERRIDE;
+
+ virtual bool SetPeerIdentityPropertyName(const grpc::string& name)
+ GRPC_OVERRIDE;
+
private:
grpc_auth_context* ctx_;
+ bool take_ownership_;
};
} // namespace grpc
diff --git a/src/cpp/common/secure_create_auth_context.cc b/src/cpp/common/secure_create_auth_context.cc
index f13d25a1dd..40bc298b64 100644
--- a/src/cpp/common/secure_create_auth_context.cc
+++ b/src/cpp/common/secure_create_auth_context.cc
@@ -34,7 +34,7 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
-#include <grpc++/support/auth_context.h>
+#include <grpc++/security/auth_context.h>
#include "src/cpp/common/secure_auth_context.h"
namespace grpc {
@@ -44,7 +44,7 @@ std::shared_ptr<const AuthContext> CreateAuthContext(grpc_call* call) {
return std::shared_ptr<const AuthContext>();
}
return std::shared_ptr<const AuthContext>(
- new SecureAuthContext(grpc_call_auth_context(call)));
+ new SecureAuthContext(grpc_call_auth_context(call), true));
}
} // namespace grpc
diff --git a/src/cpp/server/insecure_server_credentials.cc b/src/cpp/server/insecure_server_credentials.cc
index 800cd36caa..ef3cae5fd7 100644
--- a/src/cpp/server/insecure_server_credentials.cc
+++ b/src/cpp/server/insecure_server_credentials.cc
@@ -31,9 +31,10 @@
*
*/
-#include <grpc++/server_credentials.h>
+#include <grpc++/security/server_credentials.h>
#include <grpc/grpc.h>
+#include <grpc/support/log.h>
namespace grpc {
namespace {
@@ -43,6 +44,11 @@ class InsecureServerCredentialsImpl GRPC_FINAL : public ServerCredentials {
grpc_server* server) GRPC_OVERRIDE {
return grpc_server_add_insecure_http2_port(server, addr.c_str());
}
+ void SetAuthMetadataProcessor(
+ const std::shared_ptr<AuthMetadataProcessor>& processor) GRPC_OVERRIDE {
+ (void)processor;
+ GPR_ASSERT(0); // Should not be called on InsecureServerCredentials.
+ }
};
} // namespace
diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc
index f203cf7f49..dfa9229c98 100644
--- a/src/cpp/server/secure_server_credentials.cc
+++ b/src/cpp/server/secure_server_credentials.cc
@@ -31,15 +31,94 @@
*
*/
+#include <functional>
+#include <map>
+#include <memory>
+
+
+#include "src/cpp/common/secure_auth_context.h"
#include "src/cpp/server/secure_server_credentials.h"
+#include <grpc++/security/auth_metadata_processor.h>
+
namespace grpc {
+void AuthMetadataProcessorAyncWrapper::Destroy(void *wrapper) {
+ auto* w = reinterpret_cast<AuthMetadataProcessorAyncWrapper*>(wrapper);
+ delete w;
+}
+
+void AuthMetadataProcessorAyncWrapper::Process(
+ void* wrapper, grpc_auth_context* context, const grpc_metadata* md,
+ size_t num_md, grpc_process_auth_metadata_done_cb cb, void* user_data) {
+ auto* w = reinterpret_cast<AuthMetadataProcessorAyncWrapper*>(wrapper);
+ if (w->processor_ == nullptr) {
+ // Early exit.
+ cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_OK, nullptr);
+ return;
+ }
+ if (w->processor_->IsBlocking()) {
+ w->thread_pool_->Add(
+ std::bind(&AuthMetadataProcessorAyncWrapper::InvokeProcessor, w,
+ context, md, num_md, cb, user_data));
+ } else {
+ // invoke directly.
+ w->InvokeProcessor(context, md, num_md, cb, user_data);
+ }
+}
+
+void AuthMetadataProcessorAyncWrapper::InvokeProcessor(
+ grpc_auth_context* ctx,
+ const grpc_metadata* md, size_t num_md,
+ grpc_process_auth_metadata_done_cb cb, void* user_data) {
+ AuthMetadataProcessor::InputMetadata metadata;
+ for (size_t i = 0; i < num_md; i++) {
+ metadata.insert(std::make_pair(
+ md[i].key, grpc::string_ref(md[i].value, md[i].value_length)));
+ }
+ SecureAuthContext context(ctx, false);
+ AuthMetadataProcessor::OutputMetadata consumed_metadata;
+ AuthMetadataProcessor::OutputMetadata response_metadata;
+
+ Status status = processor_->Process(metadata, &context, &consumed_metadata,
+ &response_metadata);
+
+ std::vector<grpc_metadata> consumed_md;
+ for (auto it = consumed_metadata.begin(); it != consumed_metadata.end();
+ ++it) {
+ consumed_md.push_back({it->first.c_str(),
+ it->second.data(),
+ it->second.size(),
+ 0,
+ {{nullptr, nullptr, nullptr, nullptr}}});
+ }
+ std::vector<grpc_metadata> response_md;
+ for (auto it = response_metadata.begin(); it != response_metadata.end();
+ ++it) {
+ response_md.push_back({it->first.c_str(),
+ it->second.data(),
+ it->second.size(),
+ 0,
+ {{nullptr, nullptr, nullptr, nullptr}}});
+ }
+ cb(user_data, &consumed_md[0], consumed_md.size(), &response_md[0],
+ response_md.size(), static_cast<grpc_status_code>(status.error_code()),
+ status.error_message().c_str());
+}
+
int SecureServerCredentials::AddPortToServer(const grpc::string& addr,
grpc_server* server) {
return grpc_server_add_secure_http2_port(server, addr.c_str(), creds_);
}
+void SecureServerCredentials::SetAuthMetadataProcessor(
+ const std::shared_ptr<AuthMetadataProcessor>& processor) {
+ auto *wrapper = new AuthMetadataProcessorAyncWrapper(processor);
+ grpc_server_credentials_set_auth_metadata_processor(
+ creds_, {AuthMetadataProcessorAyncWrapper::Process,
+ AuthMetadataProcessorAyncWrapper::Destroy, wrapper});
+}
+
std::shared_ptr<ServerCredentials> SslServerCredentials(
const SslServerCredentialsOptions& options) {
std::vector<grpc_ssl_pem_key_cert_pair> pem_key_cert_pairs;
@@ -52,7 +131,7 @@ std::shared_ptr<ServerCredentials> SslServerCredentials(
grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create(
options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(),
&pem_key_cert_pairs[0], pem_key_cert_pairs.size(),
- options.force_client_auth);
+ options.force_client_auth, nullptr);
return std::shared_ptr<ServerCredentials>(
new SecureServerCredentials(c_creds));
}
diff --git a/src/cpp/server/secure_server_credentials.h b/src/cpp/server/secure_server_credentials.h
index d3d37b188d..4f003c6b7e 100644
--- a/src/cpp/server/secure_server_credentials.h
+++ b/src/cpp/server/secure_server_credentials.h
@@ -34,12 +34,36 @@
#ifndef GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H
#define GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H
-#include <grpc++/server_credentials.h>
+#include <memory>
+
+#include <grpc++/security/server_credentials.h>
#include <grpc/grpc_security.h>
+#include "src/cpp/server/thread_pool_interface.h"
+
namespace grpc {
+class AuthMetadataProcessorAyncWrapper GRPC_FINAL {
+ public:
+ static void Destroy(void *wrapper);
+
+ static void Process(void* wrapper, grpc_auth_context* context,
+ const grpc_metadata* md, size_t num_md,
+ grpc_process_auth_metadata_done_cb cb, void* user_data);
+
+ AuthMetadataProcessorAyncWrapper(
+ const std::shared_ptr<AuthMetadataProcessor>& processor)
+ : thread_pool_(CreateDefaultThreadPool()), processor_(processor) {}
+
+ private:
+ void InvokeProcessor(grpc_auth_context* context, const grpc_metadata* md,
+ size_t num_md, grpc_process_auth_metadata_done_cb cb,
+ void* user_data);
+ std::unique_ptr<ThreadPoolInterface> thread_pool_;
+ std::shared_ptr<AuthMetadataProcessor> processor_;
+};
+
class SecureServerCredentials GRPC_FINAL : public ServerCredentials {
public:
explicit SecureServerCredentials(grpc_server_credentials* creds)
@@ -51,8 +75,12 @@ class SecureServerCredentials GRPC_FINAL : public ServerCredentials {
int AddPortToServer(const grpc::string& addr,
grpc_server* server) GRPC_OVERRIDE;
+ void SetAuthMetadataProcessor(
+ const std::shared_ptr<AuthMetadataProcessor>& processor) GRPC_OVERRIDE;
+
private:
- grpc_server_credentials* const creds_;
+ grpc_server_credentials* creds_;
+ std::unique_ptr<AuthMetadataProcessorAyncWrapper> processor_;
};
} // namespace grpc
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index bb83c7d887..d67205e822 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -43,7 +43,7 @@
#include <grpc++/impl/rpc_service_method.h>
#include <grpc++/impl/service_type.h>
#include <grpc++/server_context.h>
-#include <grpc++/server_credentials.h>
+#include <grpc++/security/server_credentials.h>
#include <grpc++/support/time.h>
#include "src/core/profiling/timers.h"
@@ -354,7 +354,7 @@ bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) {
unknown_method_.reset(new RpcServiceMethod(
"unknown", RpcMethod::BIDI_STREAMING, new UnknownMethodHandler));
// Use of emplace_back with just constructor arguments is not accepted
- // here by gcc-4.4 because it can't match the anonymous nullptr with a
+ // here by gcc-4.4 because it can't match the anonymous nullptr with a
// proper constructor implicitly. Construct the object and use push_back.
sync_methods_->push_back(SyncRequest(unknown_method_.get(), nullptr));
}
@@ -384,7 +384,7 @@ void Server::ShutdownInternal(gpr_timespec deadline) {
// Spin, eating requests until the completion queue is completely shutdown.
// If the deadline expires then cancel anything that's pending and keep
// spinning forever until the work is actually drained.
- // Since nothing else needs to touch state guarded by mu_, holding it
+ // Since nothing else needs to touch state guarded by mu_, holding it
// through this loop is fine.
SyncRequest* request;
bool ok;
diff --git a/src/cpp/server/server_credentials.cc b/src/cpp/server/server_credentials.cc
index be3a7425e0..8495916178 100644
--- a/src/cpp/server/server_credentials.cc
+++ b/src/cpp/server/server_credentials.cc
@@ -31,7 +31,7 @@
*
*/
-#include <grpc++/server_credentials.h>
+#include <grpc++/security/server_credentials.h>
namespace grpc {
diff --git a/src/cpp/util/string_ref.cc b/src/cpp/util/string_ref.cc
index eb54f65e3a..c42033f61f 100644
--- a/src/cpp/util/string_ref.cc
+++ b/src/cpp/util/string_ref.cc
@@ -36,6 +36,7 @@
#include <string.h>
#include <algorithm>
+#include <iostream>
namespace grpc {
@@ -80,7 +81,7 @@ size_t string_ref::find(string_ref s) const {
}
size_t string_ref::find(char c) const {
- auto it = std::find_if(cbegin(), cend(), [c](char cc) { return cc == c; });
+ auto it = std::find(cbegin(), cend(), c);
return it == cend() ? npos : std::distance(cbegin(), it);
}