Merge pull request #16116 from yihuazhang/C++_wrapper_for_local_credentials

Add a C++ wrapper for local credentials
pull/16165/head
yihuaz 6 years ago committed by GitHub
commit 782e5c2b8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      include/grpc/grpc_security.h
  2. 6
      include/grpc/grpc_security_constants.h
  3. 5
      include/grpcpp/security/credentials.h
  4. 4
      include/grpcpp/security/server_credentials.h
  5. 7
      src/cpp/client/secure_credentials.cc
  6. 6
      src/cpp/server/secure_server_credentials.cc

@ -587,12 +587,6 @@ GRPCAPI grpc_server_credentials* grpc_alts_server_credentials_create(
/** --- Local channel/server credentials --- **/ /** --- 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 * This method creates a local channel credential object. It is used for
* experimental purpose for now and subject to change. * experimental purpose for now and subject to change.

@ -100,6 +100,12 @@ typedef enum {
GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
} grpc_ssl_client_certificate_request_type; } 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 #ifdef __cplusplus
} }
#endif #endif

@ -23,6 +23,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/impl/codegen/grpc_library.h> #include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/security/auth_context.h> #include <grpcpp/security/auth_context.h>
#include <grpcpp/support/status.h> #include <grpcpp/support/status.h>
@ -234,6 +235,10 @@ struct AltsCredentialsOptions {
std::shared_ptr<ChannelCredentials> AltsCredentials( std::shared_ptr<ChannelCredentials> AltsCredentials(
const AltsCredentialsOptions& options); const AltsCredentialsOptions& options);
/// Builds Local Credentials.
std::shared_ptr<ChannelCredentials> LocalCredentials(
grpc_local_connect_type type);
} // namespace experimental } // namespace experimental
} // namespace grpc } // namespace grpc

@ -97,6 +97,10 @@ struct AltsServerCredentialsOptions {
std::shared_ptr<ServerCredentials> AltsServerCredentials( std::shared_ptr<ServerCredentials> AltsServerCredentials(
const AltsServerCredentialsOptions& options); const AltsServerCredentialsOptions& options);
/// Builds Local ServerCredentials.
std::shared_ptr<ServerCredentials> LocalServerCredentials(
grpc_local_connect_type type);
} // namespace experimental } // namespace experimental
} // namespace grpc } // namespace grpc

@ -107,6 +107,13 @@ std::shared_ptr<ChannelCredentials> AltsCredentials(
return WrapChannelCredentials(c_creds); 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 } // namespace experimental
// Builds credentials for use when running in GCE // Builds credentials for use when running in GCE

@ -139,5 +139,11 @@ std::shared_ptr<ServerCredentials> AltsServerCredentials(
new SecureServerCredentials(c_creds)); 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 experimental
} // namespace grpc } // namespace grpc

Loading…
Cancel
Save