DKNet.EfCore.DataAuthorization
9.0.37
See the version list below for details.
dotnet add package DKNet.EfCore.DataAuthorization --version 9.0.37
NuGet\Install-Package DKNet.EfCore.DataAuthorization -Version 9.0.37
<PackageReference Include="DKNet.EfCore.DataAuthorization" Version="9.0.37" />
<PackageVersion Include="DKNet.EfCore.DataAuthorization" Version="9.0.37" />
<PackageReference Include="DKNet.EfCore.DataAuthorization" />
paket add DKNet.EfCore.DataAuthorization --version 9.0.37
#r "nuget: DKNet.EfCore.DataAuthorization, 9.0.37"
#:package DKNet.EfCore.DataAuthorization@9.0.37
#addin nuget:?package=DKNet.EfCore.DataAuthorization&version=9.0.37
#tool nuget:?package=DKNet.EfCore.DataAuthorization&version=9.0.37
DKNet.EfCore.DataAuthorization
A .NET library for secure, multi-tenant data authorization in Entity Framework Core. Enables automatic filtering of data based on ownership, supports DDD and API scenarios, and is designed for extensibility.
Features
- Automatic global query filtering based on data ownership keys
- Interfaces for associating entities with owners (
IOwnedBy
), providing ownership keys (IDataOwnerProvider
), and integrating with DbContext (IDataOwnerDbContext
) - Extension methods for easy setup via dependency injection (
EfCoreDataAuthSetup
) - Support for multi-tenancy and secure data isolation
- .NET 9.0 compatible
Installation
Add the NuGet package to your project:
dotnet add package DKNet.EfCore.DataAuthorization
Usage
Register the data authorization provider and setup in your DI container:
using Microsoft.Extensions.DependencyInjection;
using DKNet.EfCore.DataAuthorization;
services.AddAutoDataKeyProvider<MyDbContext, MyOwnerProvider>();
Implement IOwnedBy
on your entities:
public class Document : IOwnedBy
{
public string? OwnedBy { get; private set; }
public void SetOwnedBy(string ownerKey) => OwnedBy = ownerKey;
}
Implement IDataOwnerProvider
to supply ownership keys and accessible keys:
public class MyOwnerProvider : IDataOwnerProvider
{
public IEnumerable<string> GetAccessibleKeys() => ...; // e.g., from user context
public string GetOwnershipKey() => ...; // e.g., current user's tenant key
}
API
EfCoreDataAuthSetup.AddAutoDataKeyProvider<TDbContext, TProvider>(IServiceCollection)
: Registers automatic data key management for a DbContext.IOwnedBy
: Interface for entities supporting ownership, with methods to get/set the owner key.IDataOwnerProvider
: Interface for providing accessible keys and ownership key for new entities.IDataOwnerDbContext
: Interface for DbContexts supporting data authorization, exposing accessible keys.
License
MIT © 2026 drunkcoding
Repository
https://github.com/baoduy/DKNet
Contributing
Pull requests and issues are welcome!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net9.0
- DKNet.EfCore.Extensions (>= 9.0.37)
- DKNet.EfCore.Hooks (>= 9.0.37)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
9.0.38 | 11 | 9/24/2025 |
9.0.37 | 32 | 9/23/2025 |
9.0.36 | 56 | 9/23/2025 |
9.0.35 | 34 | 9/23/2025 |
9.0.34 | 45 | 9/23/2025 |
9.0.33 | 70 | 9/21/2025 |
9.0.32 | 64 | 9/21/2025 |
9.0.31 | 240 | 9/19/2025 |
9.0.30 | 244 | 9/18/2025 |
9.0.29 | 239 | 9/18/2025 |
9.0.28 | 264 | 9/17/2025 |
9.0.27 | 256 | 9/17/2025 |
9.0.26 | 258 | 9/16/2025 |
9.0.25 | 214 | 9/15/2025 |
9.0.24 | 200 | 9/15/2025 |
9.0.23 | 110 | 9/6/2025 |
9.0.22 | 160 | 9/3/2025 |
9.0.21 | 131 | 9/1/2025 |
9.0.20 | 155 | 7/15/2025 |
9.0.19 | 150 | 7/14/2025 |
9.0.18 | 154 | 7/14/2025 |
9.0.17 | 148 | 7/14/2025 |
9.0.16 | 121 | 7/11/2025 |
9.0.15 | 123 | 7/11/2025 |
9.0.14 | 131 | 7/11/2025 |
9.0.13 | 139 | 7/11/2025 |
9.0.12 | 153 | 7/8/2025 |
9.0.11 | 143 | 7/8/2025 |
9.0.10 | 145 | 7/7/2025 |
9.0.9 | 141 | 7/2/2025 |
9.0.8 | 154 | 7/2/2025 |
9.0.7 | 156 | 7/1/2025 |
9.0.6 | 146 | 6/30/2025 |
9.0.5 | 145 | 6/24/2025 |
9.0.4 | 158 | 6/24/2025 |
9.0.3 | 139 | 6/23/2025 |
9.0.2 | 152 | 6/23/2025 |
9.0.1 | 147 | 6/23/2025 |