DKNet.EfCore.DataAuthorization
9.5.2
See the version list below for details.
dotnet add package DKNet.EfCore.DataAuthorization --version 9.5.2
NuGet\Install-Package DKNet.EfCore.DataAuthorization -Version 9.5.2
<PackageReference Include="DKNet.EfCore.DataAuthorization" Version="9.5.2" />
<PackageVersion Include="DKNet.EfCore.DataAuthorization" Version="9.5.2" />
<PackageReference Include="DKNet.EfCore.DataAuthorization" />
paket add DKNet.EfCore.DataAuthorization --version 9.5.2
#r "nuget: DKNet.EfCore.DataAuthorization, 9.5.2"
#:package DKNet.EfCore.DataAuthorization@9.5.2
#addin nuget:?package=DKNet.EfCore.DataAuthorization&version=9.5.2
#tool nuget:?package=DKNet.EfCore.DataAuthorization&version=9.5.2
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.5.2)
- DKNet.EfCore.Hooks (>= 9.5.2)
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.5.15 | 37 | 10/15/2025 |
9.5.14 | 44 | 10/14/2025 |
9.5.13 | 34 | 10/14/2025 |
9.5.12 | 30 | 10/14/2025 |
9.5.11 | 38 | 10/14/2025 |
9.5.10 | 35 | 10/14/2025 |
9.5.9 | 35 | 10/13/2025 |
9.5.8 | 56 | 10/11/2025 |
9.5.7 | 67 | 10/10/2025 |
9.5.6 | 69 | 10/10/2025 |
9.5.5 | 73 | 10/10/2025 |
9.5.4 | 79 | 10/10/2025 |
9.5.3 | 182 | 10/8/2025 |
9.5.2 | 148 | 10/8/2025 |
9.5.1 | 173 | 10/7/2025 |
9.0.42 | 156 | 10/6/2025 |
9.0.41 | 174 | 10/2/2025 |
9.0.40 | 131 | 9/27/2025 |
9.0.39 | 144 | 9/26/2025 |
9.0.38 | 174 | 9/24/2025 |
9.0.37 | 158 | 9/23/2025 |
9.0.36 | 180 | 9/23/2025 |
9.0.35 | 158 | 9/23/2025 |
9.0.34 | 183 | 9/23/2025 |
9.0.33 | 164 | 9/21/2025 |
9.0.32 | 158 | 9/21/2025 |
9.0.31 | 269 | 9/19/2025 |
9.0.30 | 280 | 9/18/2025 |
9.0.29 | 265 | 9/18/2025 |
9.0.28 | 291 | 9/17/2025 |
9.0.27 | 283 | 9/17/2025 |
9.0.26 | 274 | 9/16/2025 |
9.0.25 | 241 | 9/15/2025 |
9.0.24 | 226 | 9/15/2025 |
9.0.23 | 127 | 9/6/2025 |
9.0.22 | 165 | 9/3/2025 |
9.0.21 | 147 | 9/1/2025 |
9.0.20 | 167 | 7/15/2025 |
9.0.19 | 162 | 7/14/2025 |
9.0.18 | 166 | 7/14/2025 |
9.0.17 | 160 | 7/14/2025 |
9.0.16 | 133 | 7/11/2025 |
9.0.15 | 135 | 7/11/2025 |
9.0.14 | 143 | 7/11/2025 |
9.0.13 | 154 | 7/11/2025 |
9.0.12 | 165 | 7/8/2025 |
9.0.11 | 155 | 7/8/2025 |
9.0.10 | 158 | 7/7/2025 |
9.0.9 | 154 | 7/2/2025 |
9.0.8 | 156 | 7/2/2025 |
9.0.7 | 168 | 7/1/2025 |
9.0.6 | 148 | 6/30/2025 |
9.0.5 | 158 | 6/24/2025 |
9.0.4 | 170 | 6/24/2025 |
9.0.3 | 141 | 6/23/2025 |
9.0.2 | 154 | 6/23/2025 |
9.0.1 | 151 | 6/23/2025 |