Naravel.Queue.Encryption
0.2.0
dotnet add package Naravel.Queue.Encryption --version 0.2.0
NuGet\Install-Package Naravel.Queue.Encryption -Version 0.2.0
<PackageReference Include="Naravel.Queue.Encryption" Version="0.2.0" />
<PackageVersion Include="Naravel.Queue.Encryption" Version="0.2.0" />
<PackageReference Include="Naravel.Queue.Encryption" />
paket add Naravel.Queue.Encryption --version 0.2.0
#r "nuget: Naravel.Queue.Encryption, 0.2.0"
#:package Naravel.Queue.Encryption@0.2.0
#addin nuget:?package=Naravel.Queue.Encryption&version=0.2.0
#tool nuget:?package=Naravel.Queue.Encryption&version=0.2.0
Naravel.Queue.Encryption
Optional Naravel.Queue adapter that encrypts the payload of jobs marked IShouldBeEncrypted with ASP.NET Core Data Protection. Unmarked jobs keep the existing wire format.
| Fact | Detail |
|---|---|
| Install | dotnet add package Naravel.Queue.Encryption |
| Targets | .NET 10 |
| Needs | Naravel.Encryption and Naravel.Queue, which NuGet installs with it, and a queue driver package of your own |
| Marker | IShouldBeEncrypted, an empty interface on the job class |
What you get
- Opt in per job. Only classes that implement
IShouldBeEncryptedare stored encrypted; every other job keeps the existing wire format. - ASP.NET Core Data Protection does the work. Naravel adds no cryptography of its own.
- Never plaintext where it is registered. A marked job is neither sent nor run as plaintext by an application that registered the package.
- Undecryptable jobs fail normally. They take the usual retry and failed-job path, and the error says to check the shared key ring and application name first.
Quick start
using Naravel.Queue.Encryption;
using Naravel.Queue.Extensions;
using Naravel.Queue.Jobs;
using Naravel.Queue.Memory;
// AddMemoryDriver comes from Naravel.Queue.Memory, which this package does not install: use the driver package you already have
// AddQueue goes first: the encryption wraps the job serializer that it registers
builder.Services.AddQueue(builder.Configuration).AddMemoryDriver(builder.Configuration);
builder.Services.AddDataProtection() // the same key ring and application name in every producer and worker
.SetApplicationName("my-shop")
.PersistKeysToFileSystem(new DirectoryInfo("/shared/keys"));
builder.Services.AddNaravelQueueEncryption();
public sealed class ChargeCard : Job, IShouldBeEncrypted
{
public string CardNumber { get; set; } = "";
public override Task HandleAsync(JobContext context, CancellationToken cancellationToken) =>
Task.CompletedTask; // your work goes here
}
Call AddNaravelQueueEncryption in every application that dispatches marked jobs and in every worker: a dispatching application without it sends a marked job as plaintext, and a worker without it cannot decrypt one. If a producer and its worker do not share the key ring and the application name, the worker cannot decrypt and every marked job fails with DecryptException. A job that was queued as plaintext before its class was marked is refused unless you set AddNaravelQueueEncryption(o => o.AcceptPlaintextForMarkedJobs = true) for a deploy window. AddNaravelQueueEncryption throws if AddQueue has not been called before it.
Related packages
| Package | Adds |
|---|---|
Naravel.Encryption |
The Encrypt and Decrypt facade over Data Protection |
Naravel.Queue |
Jobs, retries and the background worker whose payloads this package encrypts |
Learn more
- Encryption: English guide
- Queue: English guide
- Changelog · Source and issues · MIT license
Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Naravel.Encryption (>= 0.2.0)
- Naravel.Queue (>= 0.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes: https://github.com/km-arc/Naravel/releases/tag/v0.2.0 - full history: https://github.com/km-arc/Naravel/blob/main/CHANGELOG.md