diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 4f3efae4be5d64b6188e50689af240cff64245c6..f4e90a5ef58fecd8cc09b7259e2670ff87aabe70 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -276,6 +276,9 @@ typedef struct { /* State that will be set as the first parameter of the methods above. */ void *state; + + /* Type of credentials that this plugin is implementing. */ + const char *type; } grpc_metadata_credentials_plugin; /* Creates a credentials object from a plugin. */ diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c index 806f9a6f1c5c2c477bcb7ba2a8e40cf0fb9073de..751665b49477c9e03bd4bcdf7e6c3751b33da9ad 100644 --- a/src/core/security/credentials.c +++ b/src/core/security/credentials.c @@ -1210,7 +1210,7 @@ grpc_call_credentials *grpc_metadata_credentials_create_from_plugin( (reserved)); GPR_ASSERT(reserved == NULL); memset(c, 0, sizeof(*c)); - c->base.type = GRPC_CALL_CREDENTIALS_TYPE_METADATA_PLUGIN; + c->base.type = plugin.type; c->base.vtable = &plugin_vtable; gpr_ref_init(&c->base.refcount, 1); c->plugin = plugin; diff --git a/src/core/security/credentials.h b/src/core/security/credentials.h index 79caee7f99d0ccd7a1201538c001b4d0d5332896..0ce33d5e7cd56bb65c05427dc0e9efaa6cd8dbdc 100644 --- a/src/core/security/credentials.h +++ b/src/core/security/credentials.h @@ -59,7 +59,6 @@ typedef enum { "FakeTransportSecurity" #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_IAM "Iam" #define GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE "Composite" diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index fa374f808a044cccd10b43eed9dcfa9c83895ae6..bd68228460296f3eeabe81570e37a765ff4f1305 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -208,7 +208,7 @@ std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin( new MetadataCredentialsPluginWrapper(std::move(plugin)); grpc_metadata_credentials_plugin c_plugin = { MetadataCredentialsPluginWrapper::GetMetadata, - MetadataCredentialsPluginWrapper::Destroy, wrapper}; + MetadataCredentialsPluginWrapper::Destroy, wrapper, ""}; return WrapCallCredentials( grpc_metadata_credentials_create_from_plugin(c_plugin, nullptr)); } diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index e6a2664c53d63b34283e8aa91539e0d66a25b9d3..b8705c49d320db1c046a590cce9383a4dc5cc00f 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -950,6 +950,7 @@ GPR_EXPORT grpc_call_credentials *GPR_CALLTYPE grpcsharp_metadata_credentials_cr plugin.get_metadata = grpcsharp_get_metadata_handler; plugin.destroy = grpcsharp_metadata_credentials_destroy_handler; plugin.state = (void*)(gpr_intptr)metadata_interceptor; + plugin.type = ""; return grpc_metadata_credentials_create_from_plugin(plugin, NULL); } diff --git a/src/node/ext/call_credentials.cc b/src/node/ext/call_credentials.cc index d0d7140bb44eb95d5f9ed84293d3c4b7e78b9b3f..8cbfb1ebea0c934d8b10ff968e2b343102005ae3 100644 --- a/src/node/ext/call_credentials.cc +++ b/src/node/ext/call_credentials.cc @@ -162,6 +162,7 @@ NAN_METHOD(CallCredentials::CreateFromPlugin) { plugin.get_metadata = plugin_get_metadata; plugin.destroy = plugin_destroy_state; plugin.state = reinterpret_cast<void*>(state); + plugin.type = ""; grpc_call_credentials *creds = grpc_metadata_credentials_create_from_plugin( plugin, NULL); info.GetReturnValue().Set(WrapStruct(creds));