diff --git a/src/Contrib.KafkaFlow.CryptoShredding.Avro/Contrib.KafkaFlow.CryptoShredding.Avro.csproj b/src/Contrib.KafkaFlow.CryptoShredding.Avro/Contrib.KafkaFlow.CryptoShredding.Avro.csproj index adeae54..42e52d8 100644 --- a/src/Contrib.KafkaFlow.CryptoShredding.Avro/Contrib.KafkaFlow.CryptoShredding.Avro.csproj +++ b/src/Contrib.KafkaFlow.CryptoShredding.Avro/Contrib.KafkaFlow.CryptoShredding.Avro.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/src/Contrib.KafkaFlow.CryptoShredding.Avro/Readme.md b/src/Contrib.KafkaFlow.CryptoShredding.Avro/Readme.md index 4971a52..5e2e728 100644 --- a/src/Contrib.KafkaFlow.CryptoShredding.Avro/Readme.md +++ b/src/Contrib.KafkaFlow.CryptoShredding.Avro/Readme.md @@ -33,6 +33,66 @@ sensitiveData = EncryptedString.FromPlain("secret-value"); To prevent accidental leakage of secrets, `EncryptedString.Plain` cannot be serialized to Avro. An attempt to do so will result in an exception. +### Generating Avro types + +Here is an example of an Avro schema that uses encrypted secrets: + +```avro +{ + "type": "record", + "name": "EncryptedMessage", + "namespace": "TestContract", + + "fields": [ + { "name": "secret", + "type": { "type": "string", "logicalType": "encrypted-string" } } + ] +} +``` + +C# types can be generated using the [avrogen](https://www.nuget.org/packages/Apache.Avro.Tools) tool +or by using `Contrib.KafkaFlow.CryptoShredding.Avro.Analyzers` package. + +In both cases, make sure to register `EncryptedString` as a logical type: + +```csharp +LogicalTypeFactory.Instance.Register(new EncryptedStringLogicalType()); +``` + +### Using avrogen + +Install [avrogen](https://www.nuget.org/packages/Apache.Avro.Tools): + +```bash +$ dotnet tool install Apache.Avro.Tools +``` + +Then generate C# types: + +```bash +$ dotnet avrogen -s +``` + +### Using Avro Analyzers + +Reference the package in your `.csproj` file: + +```xml + +``` +and add `*.avsc` files: + +```xml + + + +``` + +C# classes will be generated automatically for all schemas in the `avro` directory. + ## Encryption Process For serialization to occur, the secrets must be encrypted first, converting `EncryptedString.Plain` into `EncryptedString.Encrypted`. The diff --git a/src/Contrib.KafkaFlow.Outbox/Contrib.KafkaFlow.Outbox.csproj b/src/Contrib.KafkaFlow.Outbox/Contrib.KafkaFlow.Outbox.csproj index 7d534ea..bcc2db2 100644 --- a/src/Contrib.KafkaFlow.Outbox/Contrib.KafkaFlow.Outbox.csproj +++ b/src/Contrib.KafkaFlow.Outbox/Contrib.KafkaFlow.Outbox.csproj @@ -8,7 +8,7 @@ latest true latest - + Readme.md @@ -23,4 +23,8 @@ + + + + diff --git a/src/Contrib.KafkaFlow.ProcessManagers/Contrib.KafkaFlow.ProcessManagers.csproj b/src/Contrib.KafkaFlow.ProcessManagers/Contrib.KafkaFlow.ProcessManagers.csproj index 54b7a12..cc7d9b4 100644 --- a/src/Contrib.KafkaFlow.ProcessManagers/Contrib.KafkaFlow.ProcessManagers.csproj +++ b/src/Contrib.KafkaFlow.ProcessManagers/Contrib.KafkaFlow.ProcessManagers.csproj @@ -8,6 +8,7 @@ latest true latest + Readme.md @@ -20,4 +21,8 @@ + + + +