aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar yihuaz <yihuaz@google.com>2018-07-27 09:17:36 -0700
committerGravatar GitHub <noreply@github.com>2018-07-27 09:17:36 -0700
commit782e5c2b8dc6973b6fc0959ba08da0f5b9db2f6f (patch)
treed423c02610acf25fb24c91adc62549fd1f58340f
parent8fb45dc24f4c5ab68caa902eeb0cca38ec481395 (diff)
parentacc6ba0c2456d51fef133008ec9a3aac1451d521 (diff)
Merge pull request #16116 from yihuazhang/C++_wrapper_for_local_credentials
Add a C++ wrapper for local credentials
-rw-r--r--include/grpc/grpc_security.h6
-rw-r--r--include/grpc/grpc_security_constants.h6
-rw-r--r--include/grpcpp/security/credentials.h5
-rw-r--r--include/grpcpp/security/server_credentials.h4
-rw-r--r--src/cpp/client/secure_credentials.cc7
-rw-r--r--src/cpp/server/secure_server_credentials.cc6
6 files changed, 28 insertions, 6 deletions
diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h
index 102d20fcf9..02d87a493a 100644
--- a/include/grpc/grpc_security.h
+++ b/include/grpc/grpc_security.h
@@ -588,12 +588,6 @@ GRPCAPI grpc_server_credentials* grpc_alts_server_credentials_create(
/** --- Local channel/server credentials --- **/
/**
- * Type of local connection for which local channel/server credentials will be
- * applied. It only supports UDS for now.
- */
-typedef enum { UDS = 0 } grpc_local_connect_type;
-
-/**
* This method creates a local channel credential object. It is used for
* experimental purpose for now and subject to change.
*
diff --git a/include/grpc/grpc_security_constants.h b/include/grpc/grpc_security_constants.h
index 92580ea35e..944a1e927f 100644
--- a/include/grpc/grpc_security_constants.h
+++ b/include/grpc/grpc_security_constants.h
@@ -100,6 +100,12 @@ typedef enum {
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
} grpc_ssl_client_certificate_request_type;
+/**
+ * Type of local connection for which local channel/server credentials will be
+ * applied. It only supports UDS for now.
+ */
+typedef enum { UDS = 0 } grpc_local_connect_type;
+
#ifdef __cplusplus
}
#endif
diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h
index 36d95d1b42..bfadc15df5 100644
--- a/include/grpcpp/security/credentials.h
+++ b/include/grpcpp/security/credentials.h
@@ -23,6 +23,7 @@
#include <memory>
#include <vector>
+#include <grpc/grpc_security_constants.h>
#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/support/status.h>
@@ -234,6 +235,10 @@ struct AltsCredentialsOptions {
std::shared_ptr<ChannelCredentials> AltsCredentials(
const AltsCredentialsOptions& options);
+/// Builds Local Credentials.
+std::shared_ptr<ChannelCredentials> LocalCredentials(
+ grpc_local_connect_type type);
+
} // namespace experimental
} // namespace grpc
diff --git a/include/grpcpp/security/server_credentials.h b/include/grpcpp/security/server_credentials.h
index cf57e275f5..bd00a0a173 100644
--- a/include/grpcpp/security/server_credentials.h
+++ b/include/grpcpp/security/server_credentials.h
@@ -97,6 +97,10 @@ struct AltsServerCredentialsOptions {
std::shared_ptr<ServerCredentials> AltsServerCredentials(
const AltsServerCredentialsOptions& options);
+/// Builds Local ServerCredentials.
+std::shared_ptr<ServerCredentials> LocalServerCredentials(
+ grpc_local_connect_type type);
+
} // namespace experimental
} // namespace grpc
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index bdb6359632..e48fbeb86d 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -107,6 +107,13 @@ std::shared_ptr<ChannelCredentials> AltsCredentials(
return WrapChannelCredentials(c_creds);
}
+// Builds Local Credentials
+std::shared_ptr<ChannelCredentials> LocalCredentials(
+ grpc_local_connect_type type) {
+ GrpcLibraryCodegen init; // To call grpc_init().
+ return WrapChannelCredentials(grpc_local_credentials_create(type));
+}
+
} // namespace experimental
// Builds credentials for use when running in GCE
diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc
index a5af25751a..536bf022dd 100644
--- a/src/cpp/server/secure_server_credentials.cc
+++ b/src/cpp/server/secure_server_credentials.cc
@@ -139,5 +139,11 @@ std::shared_ptr<ServerCredentials> AltsServerCredentials(
new SecureServerCredentials(c_creds));
}
+std::shared_ptr<ServerCredentials> LocalServerCredentials(
+ grpc_local_connect_type type) {
+ return std::shared_ptr<ServerCredentials>(
+ new SecureServerCredentials(grpc_local_server_credentials_create(type)));
+}
+
} // namespace experimental
} // namespace grpc