aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar Julien Boeuf <jboeuf@google.com>2015-08-10 12:45:17 -0700
committerGravatar Julien Boeuf <jboeuf@google.com>2015-08-13 17:25:52 -0700
commitc2274e706937c1742e72a20a889ce1283d12af52 (patch)
treee33b3eb2b86119ed634c587e8bfb62ad1e7e1bfe /include/grpc++
parent8d428f1e6d0f7b76f8b737ae63f7a74b97279a1d (diff)
Adding C++ auth metadata processor.
- We always do the processing asynchronously but maintain a synchronous API for the implementor of the processor. - there are a lot of string copies right now. Having a StringPiece object in grpc++ would really help with that (as we would use it for C++ metadata). - Please review the API carefully and if you're happy with it, I'll proceed with tests.
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/auth_context.h5
-rw-r--r--include/grpc++/auth_metadata_processor.h60
-rw-r--r--include/grpc++/server_credentials.h5
3 files changed, 70 insertions, 0 deletions
diff --git a/include/grpc++/auth_context.h b/include/grpc++/auth_context.h
index f8ea8ad6f4..0b5f856d3f 100644
--- a/include/grpc++/auth_context.h
+++ b/include/grpc++/auth_context.h
@@ -87,6 +87,11 @@ class AuthContext {
// Iteration over all the properties.
virtual AuthPropertyIterator begin() const = 0;
virtual AuthPropertyIterator end() const = 0;
+
+ // Mutation functions: should only be used by an AuthMetadataProcessor.
+ virtual void AddProperty(const grpc::string& key,
+ const grpc::string& value) = 0;
+ virtual bool SetPeerIdentityPropertyName(const grpc::string& name) = 0;
};
} // namespace grpc
diff --git a/include/grpc++/auth_metadata_processor.h b/include/grpc++/auth_metadata_processor.h
new file mode 100644
index 0000000000..e077ec0c60
--- /dev/null
+++ b/include/grpc++/auth_metadata_processor.h
@@ -0,0 +1,60 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPCXX_AUTH_METADATA_PROCESSOR_H_
+#define GRPCXX_AUTH_METADATA_PROCESSOR_H_
+
+#include <map>
+#include <string>
+
+#include <grpc++/auth_context.h>
+
+namespace grpc {
+
+class AuthMetadataProcessor {
+ public:
+ virtual ~AuthMetadataProcessor() {}
+
+ // context is read/write: it contains the properties of the channel peer and
+ // it is the job of the Process method to augment it with properties derived
+ // from the passed-in auth_metadata.
+ virtual bool Process(
+ std::multimap<grpc::string, grpc::string>& auth_metadata,
+ AuthContext* context,
+ std::multimap<grpc::string, grpc::string>* consumed_auth_metadata) = 0;
+};
+
+} // namespace grpc
+
+#endif // GRPCXX_AUTH_METADATA_PROCESSOR_H_
+
diff --git a/include/grpc++/server_credentials.h b/include/grpc++/server_credentials.h
index 11acd67e8a..d540b95e21 100644
--- a/include/grpc++/server_credentials.h
+++ b/include/grpc++/server_credentials.h
@@ -38,6 +38,7 @@
#include <vector>
#include <grpc++/config.h>
+#include <grpc++/auth_metadata_processor.h>
struct grpc_server;
@@ -54,6 +55,10 @@ class ServerCredentials {
virtual int AddPortToServer(const grpc::string& addr,
grpc_server* server) = 0;
+
+ // Has to be called before the server is started.
+ virtual void SetAuthMetadataProcessor(
+ const std::shared_ptr<AuthMetadataProcessor>& processor) = 0;
};
// Options to create ServerCredentials with SSL