Pluggable Secret store template (#164)

* Pluggable Secret store template

Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com>

* Updating proto and readme

Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com>

---------

Signed-off-by: Pravin Pushkar <ppushkar@microsoft.com>
This commit is contained in:
Pravin Pushkar 2023-10-11 23:12:45 +05:30 committed by GitHub
parent 94f37191f7
commit 5228153f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 200 additions and 65 deletions

View File

@ -10,6 +10,7 @@
<Protobuf Include="Protos\dapr\proto\components\v1\bindings.proto" ProtoRoot="Protos" GrpcServices="Client,Server" />
<Protobuf Include="Protos\dapr\proto\components\v1\pubsub.proto" ProtoRoot="Protos" GrpcServices="Client,Server" />
<Protobuf Include="Protos\dapr\proto\components\v1\state.proto" ProtoRoot="Protos" GrpcServices="Client,Server" />
<Protobuf Include="Protos\dapr\proto\components\v1\secretstore.proto" ProtoRoot="Protos" GrpcServices="Client,Server" />
<Protobuf Include="Protos\dapr\proto\components\v1\common.proto" ProtoRoot="Protos" GrpcServices="Client" />
</ItemGroup>

View File

@ -11,6 +11,9 @@
// limitations under the License.
// ------------------------------------------------------------------------
//Uncomment it import Services.
//using DaprComponents.Services;
var componentName = "my-component"; // replace by your component name
// default directory for components
var socketDir = "/tmp/dapr-components-sockets";
@ -48,6 +51,7 @@ var app = builder.Build();
// app.MapGrpcService<PubSubService>(); // Uncomment to register the PubSubService
// app.MapGrpcService<InputBindingService>(); // Uncomment to register the InputBindingService
// app.MapGrpcService<OutputBindingService>(); // Uncomment to register the OutputBindingService
// app.MapGrpcService<SecretStoreService>(); // Uncomment to register the SecretStoreService
// gRPC refletion is required for service discovery, do not remove it.
app.MapGrpcReflectionService();

View File

@ -30,6 +30,8 @@ service PubSub {
// Publish publishes a new message for the given topic.
rpc Publish(PublishRequest) returns (PublishResponse) {}
rpc BulkPublish(BulkPublishRequest) returns (BulkPublishResponse) {}
// Establishes a stream with the server (PubSub component), which sends
// messages down to the client (daprd). The client streams acknowledgements
// back to the server. The server will close the stream and return the status
@ -82,6 +84,29 @@ message PublishRequest {
string content_type = 5;
}
message BulkPublishRequest {
repeated BulkMessageEntry entries = 1;
string pubsub_name = 2;
string topic = 3;
map<string, string> metadata = 4;
}
message BulkMessageEntry {
string entry_id = 1;
bytes event = 2;
string content_type = 3;
map<string, string> metadata = 4;
}
message BulkPublishResponse {
repeated BulkPublishResponseFailedEntry failed_entries = 1;
}
message BulkPublishResponseFailedEntry {
string entry_id = 1;
string error = 2;
}
// reserved for future-proof extensibility
message PublishResponse {}

View File

@ -0,0 +1,80 @@
/*
Copyright 2023 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
syntax = "proto3";
package dapr.proto.components.v1;
import "dapr/proto/components/v1/common.proto";
option go_package = "github.com/dapr/dapr/pkg/proto/components/v1;components";
// Interface for secret store.
service SecretStore {
// Initializes the secret store with the given metadata.
rpc Init(SecretStoreInitRequest) returns (SecretStoreInitResponse) {}
// Returns a list of implemented secret store features.
rpc Features(FeaturesRequest) returns (FeaturesResponse) {}
// Get an individual secret from the store.
rpc Get(GetSecretRequest) returns (GetSecretResponse) {}
// Get all secrets from the store.
rpc BulkGet(BulkGetSecretRequest) returns (BulkGetSecretResponse) {}
// Ping the pubsub. Used for liveness porpuses.
rpc Ping(PingRequest) returns (PingResponse) {}
}
// Request to initialize the secret store.
message SecretStoreInitRequest {
MetadataRequest metadata = 1;
}
// Response from initialization.
message SecretStoreInitResponse {}
// GetSecretRequest is the message to get secret from secret store.
message GetSecretRequest {
// The name of secret key.
string key = 1;
// The metadata which will be sent to secret store components.
map<string, string> metadata = 2;
}
// GetSecretResponse is the response message to convey the requested secret.
message GetSecretResponse {
// data is the secret value. Some secret store, such as kubernetes secret
// store, can save multiple secrets for single secret key.
map<string, string> data = 1;
}
// BulkGetSecretRequest is the message to get the secrets from secret store.
message BulkGetSecretRequest {
// The metadata which will be sent to secret store components.
map<string, string> metadata = 1;
}
// SecretResponse is a map of decrypted string/string values
message SecretResponse {
map<string, string> secrets = 1;
}
// BulkGetSecretResponse is the response message to convey the requested secrets.
message BulkGetSecretResponse {
// data hold the secret values. Some secret store, such as kubernetes secret
// store, can save multiple secrets for single secret key.
map<string, SecretResponse> data = 1;
}

View File

@ -236,15 +236,25 @@ message SetRequest {
// reserved for future-proof extensibility
message SetResponse {}
message BulkDeleteRequestOptions {
int64 parallelism = 1;
}
message BulkDeleteRequest {
repeated DeleteRequest items = 1;
BulkDeleteRequestOptions options = 2;
}
// reserved for future-proof extensibility
message BulkDeleteResponse {}
message BulkGetRequestOptions {
int64 parallelism = 1;
}
message BulkGetRequest {
repeated GetRequest items = 1;
BulkGetRequestOptions options = 2;
}
message BulkStateItem {
@ -264,11 +274,15 @@ message BulkStateItem {
message BulkGetResponse {
repeated BulkStateItem items = 1;
bool got = 2;
}
message BulkSetRequestOptions {
int64 parallelism = 1;
}
message BulkSetRequest {
repeated SetRequest items = 1;
BulkSetRequestOptions options = 2;
}
// reserved for future-proof extensibility

View File

@ -4,7 +4,7 @@
| Attribute | Details |
| -------------------- | ------- |
| Dapr runtime version | 1.9.0 |
| Dapr runtime version | 1.12.0 |
| Language | .NET |
| Environment | Local |
@ -29,7 +29,7 @@ git clone https://github.com/dapr/samples.git
cd samples/pluggable-components-dotnet-sample
```
2. Examine the `./Services/Services.cs` file. You'll see four commented classes. They are `StateStoreService`, `PubSubService`, `InputBindingService` and `OutputBindingService`, their protos are defined inside `./Protos` folder. Uncomment any number of them as these serve as a unimplemented proto service that you start from.
2. Examine the `./Services/Services.cs` file. You'll see four commented classes. They are `StateStoreService`, `PubSubService`, `InputBindingService` and `OutputBindingService`, their protos are defined inside `./Protos` folder. Uncomment any number of them as these serve as an unimplemented proto service that you start from.
Uncommenting StateStoreService as an example:

View File

@ -1,62 +1,73 @@
// ------------------------------------------------------------------------
// Copyright 2022 The Dapr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
// Uncomment to import Dapr proto components namespace.
// using Dapr.Proto.Components.V1;
namespace DaprComponents.Services;
// Uncomment the lines below to implement the StateStore methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/state.proto#L123
// public class StateStoreService : StateStore.StateStoreBase
// {
// private readonly ILogger<StateStoreService> _logger;
// public StateStoreService(ILogger<StateStoreService> logger)
// {
// _logger = logger;
// }
// }
// Uncomment the lines below to implement the PubSub methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/pubsub.proto#L23
// public class PubSubService : PubSub.PubSubBase
// {
// private readonly ILogger<PubSubService> _logger;
// public PubSubService(ILogger<PubSubService> logger)
// {
// _logger = logger;
// }
// }
// Uncomment the lines below to implement the InputBindings methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/bindings.proto#L23
// public class InputBindingService : InputBinding.InputBindingBase
// {
// private readonly ILogger<InputBindingService> _logger;
// public InputBindingService(ILogger<InputBindingService> logger)
// {
// _logger = logger;
// }
// }
// Uncomment the lines below to implement the OutputBindings methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/bindings.proto#L37
// public class OutputBindingService : OutputBinding.OutputBindingBase
// {
// private readonly ILogger<OutputBindingService> _logger;
// public OutputBindingService(ILogger<OutputBindingService> logger)
// {
// _logger = logger;
// }
// }
// ------------------------------------------------------------------------
// Copyright 2022 The Dapr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
// Uncomment to import Dapr proto components namespace.
//using Dapr.Proto.Components.V1;
namespace DaprComponents.Services;
// Uncomment the lines below to implement the StateStore methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/state.proto#L123
// public class StateStoreService : StateStore.StateStoreBase
// {
// private readonly ILogger<StateStoreService> _logger;
// public StateStoreService(ILogger<StateStoreService> logger)
// {
// _logger = logger;
// }
// }
// Uncomment the lines below to implement the PubSub methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/pubsub.proto#L23
// public class PubSubService : PubSub.PubSubBase
// {
// private readonly ILogger<PubSubService> _logger;
// public PubSubService(ILogger<PubSubService> logger)
// {
// _logger = logger;
// }
// }
// Uncomment the lines below to implement the InputBindings methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/bindings.proto#L23
// public class InputBindingService : InputBinding.InputBindingBase
// {
// private readonly ILogger<InputBindingService> _logger;
// public InputBindingService(ILogger<InputBindingService> logger)
// {
// _logger = logger;
// }
// }
// Uncomment the lines below to implement the OutputBindings methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/bindings.proto#L37
//public class OutputBindingService : OutputBinding.OutputBindingBase
//{
// private readonly ILogger<OutputBindingService> _logger;
// public OutputBindingService(ILogger<OutputBindingService> logger)
// {
// _logger = logger;
// }
//}
// Uncomment the lines below to implement the Secret Store methods defined in the following protofiles
// ./Protos/dapr/proto/components/v1/secretstore.proto#23
// public class SecretStoreService : SecretStore.SecretStoreBase
// {
// private readonly ILogger<SecretStoreService> _logger;
// public SecretStoreService(ILogger<SecretStoreService> logger)
// {
// _logger = logger;
// }
// }