Also adding a credentials type to the plugin API.

The purpose of this is to be able to install a composition policy that
describes which types are incompatible and that will be enforced during
call creds composition.

If this functionality is wanted it will be done in an additive function in
the API like :

void grpc_call_credentials_set_composite_policy(
  grpc_call_credentials_composite_policy policy);
pull/4154/head
Julien Boeuf 9 years ago
parent 35b6b94667
commit caf9935e45
  1. 3
      include/grpc/grpc_security.h
  2. 2
      src/core/security/credentials.c
  3. 1
      src/core/security/credentials.h
  4. 2
      src/cpp/client/secure_credentials.cc
  5. 1
      src/csharp/ext/grpc_csharp_ext.c
  6. 1
      src/node/ext/call_credentials.cc

@ -276,6 +276,9 @@ typedef struct {
/* State that will be set as the first parameter of the methods above. */ /* State that will be set as the first parameter of the methods above. */
void *state; void *state;
/* Type of credentials that this plugin is implementing. */
const char *type;
} grpc_metadata_credentials_plugin; } grpc_metadata_credentials_plugin;
/* Creates a credentials object from a plugin. */ /* Creates a credentials object from a plugin. */

@ -1210,7 +1210,7 @@ grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
(reserved)); (reserved));
GPR_ASSERT(reserved == NULL); GPR_ASSERT(reserved == NULL);
memset(c, 0, sizeof(*c)); memset(c, 0, sizeof(*c));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_METADATA_PLUGIN; c->base.type = plugin.type;
c->base.vtable = &plugin_vtable; c->base.vtable = &plugin_vtable;
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);
c->plugin = plugin; c->plugin = plugin;

@ -59,7 +59,6 @@ typedef enum {
"FakeTransportSecurity" "FakeTransportSecurity"
#define GRPC_CALL_CREDENTIALS_TYPE_OAUTH2 "Oauth2" #define GRPC_CALL_CREDENTIALS_TYPE_OAUTH2 "Oauth2"
#define GRPC_CALL_CREDENTIALS_TYPE_METADATA_PLUGIN "Plugin"
#define GRPC_CALL_CREDENTIALS_TYPE_JWT "Jwt" #define GRPC_CALL_CREDENTIALS_TYPE_JWT "Jwt"
#define GRPC_CALL_CREDENTIALS_TYPE_IAM "Iam" #define GRPC_CALL_CREDENTIALS_TYPE_IAM "Iam"
#define GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE "Composite" #define GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE "Composite"

@ -208,7 +208,7 @@ std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin(
new MetadataCredentialsPluginWrapper(std::move(plugin)); new MetadataCredentialsPluginWrapper(std::move(plugin));
grpc_metadata_credentials_plugin c_plugin = { grpc_metadata_credentials_plugin c_plugin = {
MetadataCredentialsPluginWrapper::GetMetadata, MetadataCredentialsPluginWrapper::GetMetadata,
MetadataCredentialsPluginWrapper::Destroy, wrapper}; MetadataCredentialsPluginWrapper::Destroy, wrapper, ""};
return WrapCallCredentials( return WrapCallCredentials(
grpc_metadata_credentials_create_from_plugin(c_plugin, nullptr)); grpc_metadata_credentials_create_from_plugin(c_plugin, nullptr));
} }

@ -950,6 +950,7 @@ GPR_EXPORT grpc_call_credentials *GPR_CALLTYPE grpcsharp_metadata_credentials_cr
plugin.get_metadata = grpcsharp_get_metadata_handler; plugin.get_metadata = grpcsharp_get_metadata_handler;
plugin.destroy = grpcsharp_metadata_credentials_destroy_handler; plugin.destroy = grpcsharp_metadata_credentials_destroy_handler;
plugin.state = (void*)(gpr_intptr)metadata_interceptor; plugin.state = (void*)(gpr_intptr)metadata_interceptor;
plugin.type = "";
return grpc_metadata_credentials_create_from_plugin(plugin, NULL); return grpc_metadata_credentials_create_from_plugin(plugin, NULL);
} }

@ -162,6 +162,7 @@ NAN_METHOD(CallCredentials::CreateFromPlugin) {
plugin.get_metadata = plugin_get_metadata; plugin.get_metadata = plugin_get_metadata;
plugin.destroy = plugin_destroy_state; plugin.destroy = plugin_destroy_state;
plugin.state = reinterpret_cast<void*>(state); plugin.state = reinterpret_cast<void*>(state);
plugin.type = "";
grpc_call_credentials *creds = grpc_metadata_credentials_create_from_plugin( grpc_call_credentials *creds = grpc_metadata_credentials_create_from_plugin(
plugin, NULL); plugin, NULL);
info.GetReturnValue().Set(WrapStruct(creds)); info.GetReturnValue().Set(WrapStruct(creds));

Loading…
Cancel
Save